/// <inheritdoc /> public async Task <bool> CheckFeatureAsync(FeatureFlagType featureFlag) { using var response = await HttpClient.GetAsync($"/ph-api/metadata/features/{featureFlag.ToString().ToLower()}"); var content = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { throw new HttPlaceholderClientException(response.StatusCode, content); } var result = JsonConvert.DeserializeObject <FeatureResultDto>(content); return(result is { Enabled : true });
/// <summary> /// Constructs a <see cref="FeatureIsEnabledQuery"/> instance. /// </summary> /// <param name="featureFlag">The <see cref="FeatureFlagType"/> to check for.</param> public FeatureIsEnabledQuery(FeatureFlagType featureFlag) { FeatureFlag = featureFlag; }
/// <summary> /// Constructs a <see cref="FeatureResultModel"/> instance. /// </summary> /// <param name="featureFlag">The feature flag.</param> /// <param name="enabled">Whether the feature is enabled or not.</param> public FeatureResultModel(FeatureFlagType featureFlag, bool enabled) { FeatureFlag = featureFlag; Enabled = enabled; }
public async Task <ActionResult <FeatureResultDto> > CheckFeature([FromRoute] FeatureFlagType featureFlag) => Ok(Mapper.Map <FeatureResultDto>(await Mediator.Send(new FeatureIsEnabledQuery(featureFlag))));
public FeatureFlagInfoAttribute(string name, string description, FeatureFlagType featureFlagType) { Name = name ?? throw new ArgumentNullException(nameof(name)); Description = description ?? throw new ArgumentNullException(nameof(description)); FeatureFlagType = featureFlagType; }