public FeatureTagHelper(IFeatureService featuresService, EsquioAspNetCoreDiagnostics diagnostics) { _featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); _diagnostics = diagnostics ?? throw new ArgumentNullException(nameof(diagnostics)); }
public async Task Invoke(HttpContext context, IFeatureService featureService, EsquioAspNetCoreDiagnostics diagnostics) { var evaluationsResponse = new List <EvaluationResponse>(); var names = context.Request .Query[FEATURENAME_QUERY_PARAMETER_NAME]; foreach (var featureName in names) { try { diagnostics.EsquioMiddlewareEvaluatingFeature(featureName); var isEnabled = await featureService .IsEnabledAsync(featureName, context?.RequestAborted ?? CancellationToken.None); evaluationsResponse.Add(new EvaluationResponse() { Name = featureName, Enabled = isEnabled }); } catch (Exception exception) { diagnostics.EsquioMiddlewareThrow(featureName, exception); await WriteError(context, featureName); return; } } diagnostics.EsquioMiddlewareSuccess(); await WriteResponse(context, evaluationsResponse); }
public FeatureMatcherPolicy(EsquioAspNetCoreDiagnostics diagnostics) { _diagnostics = diagnostics ?? throw new ArgumentNullException(nameof(diagnostics)); }