Serving Front-end Flags

To ensure consistency between back-end and front-end decisions, the computed flags can be served to the user.

private readonly IFeatureManagerSnapshot _featureSnapshotManager;

public HomeController(IFeatureManagerSnapshot featureSnapshotManager)
{
    _featureSnapshotManager = featureSnapshotManager;
}

[Route("flags.json")]
public async Task<IActionResult> FeatureFlags()
{
    var model = new Dictionary<string, bool>();

    await foreach (var name in _featureSnapshotManager.GetFeatureNamesAsync())
        model.Add(name, await _featureSnapshotManager.IsEnabledAsync(name));

    return Ok(model);
}

Last updated