< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.WebApi.EdgePipeline
Assembly: ArturRios.Heimdall.WebApi
File(s): /home/ci/agent/workspace/heimdall-api-docs_main/app/src/Presentation/ArturRios.Heimdall.WebApi/Registration/EdgePipeline.cs
Line coverage
100%
Covered lines: 36
Uncovered lines: 0
Coverable lines: 36
Total lines: 52
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage
100%
Covered methods: 2
Fully covered methods: 2
Total methods: 2
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure(...)100%22100%

File(s)

/home/ci/agent/workspace/heimdall-api-docs_main/app/src/Presentation/ArturRios.Heimdall.WebApi/Registration/EdgePipeline.cs

#LineLine coverage
 1using ArturRios.Data.Relational.Core.DependencyInjection;
 2using ArturRios.Heimdall.WebApi.Metrics;
 3using ArturRios.Heimdall.WebApi.Security;
 4using ArturRios.Util.WebApi.Configuration;
 5using ArturRios.Util.WebApi.Security.Extensions;
 6using Microsoft.AspNetCore.Rewrite;
 7
 8namespace ArturRios.Heimdall.WebApi;
 9
 10/// <summary>
 11///     The middlewares that must run ahead of the standard pipeline. A startup filter is how they
 12///     get there: ASP.NET Core wraps the application's whole pipeline in it, so what it adds runs
 13///     before anything <c>Build</c> adds.
 14/// </summary>
 97315internal sealed class EdgePipeline(MetricsOptions metrics, SensitiveDiagnostics diagnostics) : IStartupFilter
 16{
 96617    public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next) => app =>
 96618    {
 96619        // First, ahead of everything else — the standard pipeline's ExceptionMiddleware and
 96620        // AuthenticationMiddleware included. The scrape endpoint is a terminal branch taken only on
 96621        // the metrics port, so Prometheus is never asked for a token, never rate limited, never
 96622        // subject to CORS, and the endpoint never reaches the OpenAPI document. Every request on
 96623        // the public port falls straight through, /metrics included.
 96624        app.UseHeimdallMetrics(metrics);
 96625
 96626        // The shared decision, never the environment directly: on a public host without the
 96627        // override it is off in Development too (NFR-28). This call is what Local needs; in
 96628        // Development the host adds its own page further in, which SuppressedDeveloperPageFilter
 96629        // holds to the same decision.
 96630        if (diagnostics.DeveloperExceptionPage)
 96631        {
 96532            app.UseDeveloperExceptionPage();
 96633        }
 96634
 96635        // Ahead of HTTPS redirection, which decides on the scheme: behind Traefik every request
 96636        // arrives as http, and only X-Forwarded-Proto says the caller used https. The standard
 96637        // pipeline runs the same middleware again first thing; by then the trusted hop has been
 96638        // consumed and the connection's address is no longer a proxy's, so it changes nothing.
 96639        app.UseForwardedHeaders();
 96640
 96641        app.UseHttpsRedirection();
 96642
 96643        // The health check moved under api/ so the web UI can reach it through its own host; the
 96644        // container probes and yggdrasil's status catalog still call the root addresses. Rewritten
 96645        // here, ahead of routing and authentication, so the alias runs the same endpoint with the
 96646        // same authorization, and stays out of the OpenAPI document.
 96647        app.UseRewriter(new RewriteOptions()
 96648            .AddRewrite("(?i)^healthcheck(/detailed|/ready)?/?$", "api/healthcheck$1", skipRemainingRules: true));
 96649
 96650        next(app);
 193251    };
 52}