< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Hosting.Options.MapRouteOptions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Hosting/Options/MapRouteOptions.cs
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
82%
Covered lines: 24
Uncovered lines: 5
Coverable lines: 29
Total lines: 135
Line coverage: 82.7%
Branch coverage
10%
Covered branches: 1
Total branches: 10
Branch coverage: 10%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 11/19/2025 - 17:40:50 Line coverage: 100% (15/15) Total lines: 72 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd02612/12/2025 - 17:27:19 Line coverage: 66.6% (16/24) Branch coverage: 0% (0/10) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/15/2025 - 02:23:46 Line coverage: 75% (18/24) Branch coverage: 10% (1/10) Total lines: 109 Tag: Kestrun/Kestrun@7a3839f4de2254e22daae81ab8dc7cb2f40c833001/02/2026 - 00:16:25 Line coverage: 76% (19/25) Branch coverage: 10% (1/10) Total lines: 115 Tag: Kestrun/Kestrun@8405dc23b786b9d436fba0d65fb80baa4171e1d001/12/2026 - 18:03:06 Line coverage: 80% (20/25) Branch coverage: 10% (1/10) Total lines: 115 Tag: Kestrun/Kestrun@956332ccc921363590dccd99d5707fb20b50966b02/05/2026 - 00:28:18 Line coverage: 76.9% (20/26) Branch coverage: 10% (1/10) Total lines: 121 Tag: Kestrun/Kestrun@d9261bd752e45afa789d10bc0c82b7d5724d958902/18/2026 - 08:33:07 Line coverage: 78.5% (22/28) Branch coverage: 10% (1/10) Total lines: 131 Tag: Kestrun/Kestrun@bf8a937cfb7e8936c225b9df4608f8ddd85558b103/26/2026 - 03:54:59 Line coverage: 82.1% (23/28) Branch coverage: 10% (1/10) Total lines: 131 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d04/23/2026 - 14:35:41 Line coverage: 82.7% (24/29) Branch coverage: 10% (1/10) Total lines: 135 Tag: Kestrun/Kestrun@2fdbb120ca2faaa9acf2b8d2a34a7d64b067edbe 12/12/2025 - 17:27:19 Line coverage: 66.6% (16/24) Branch coverage: 0% (0/10) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/15/2025 - 02:23:46 Line coverage: 75% (18/24) Branch coverage: 10% (1/10) Total lines: 109 Tag: Kestrun/Kestrun@7a3839f4de2254e22daae81ab8dc7cb2f40c833001/02/2026 - 00:16:25 Line coverage: 76% (19/25) Branch coverage: 10% (1/10) Total lines: 115 Tag: Kestrun/Kestrun@8405dc23b786b9d436fba0d65fb80baa4171e1d001/12/2026 - 18:03:06 Line coverage: 80% (20/25) Branch coverage: 10% (1/10) Total lines: 115 Tag: Kestrun/Kestrun@956332ccc921363590dccd99d5707fb20b50966b02/05/2026 - 00:28:18 Line coverage: 76.9% (20/26) Branch coverage: 10% (1/10) Total lines: 121 Tag: Kestrun/Kestrun@d9261bd752e45afa789d10bc0c82b7d5724d958902/18/2026 - 08:33:07 Line coverage: 78.5% (22/28) Branch coverage: 10% (1/10) Total lines: 131 Tag: Kestrun/Kestrun@bf8a937cfb7e8936c225b9df4608f8ddd85558b103/26/2026 - 03:54:59 Line coverage: 82.1% (23/28) Branch coverage: 10% (1/10) Total lines: 131 Tag: Kestrun/Kestrun@844b5179fb0492dc6b1182bae3ff65fa7365521d04/23/2026 - 14:35:41 Line coverage: 82.7% (24/29) Branch coverage: 10% (1/10) Total lines: 135 Tag: Kestrun/Kestrun@2fdbb120ca2faaa9acf2b8d2a34a7d64b067edbe

Coverage delta

Coverage delta 34 -34

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Hosting/Options/MapRouteOptions.cs

#LineLine coverage
 1using Kestrun.Callback;
 2using Kestrun.Forms;
 3using Kestrun.Utilities;
 4
 5namespace Kestrun.Hosting.Options;
 6/// <summary>
 7/// Options for mapping a route, including pattern, HTTP verbs, script code, authorization, and metadata.
 8/// </summary>
 9public class MapRouteOptions
 10{
 11    /// <summary>
 12    /// The route pattern to match for this option.
 13    /// </summary>
 80114    public string? Pattern { get; set; }
 15    /// <summary>
 16    /// The HTTP verbs (methods) that this route responds to.
 17    /// </summary>
 83818    public List<HttpVerb> HttpVerbs { get; set; } = [];
 19    /// <summary>
 20    /// Authorization Scheme names required for this route.
 21    /// </summary>
 45222    public List<string> RequireSchemes { get; init; } = []; // Authorization scheme name, if any
 23    /// <summary>
 24    /// Authorization policy names required for this route.
 25    /// </summary>
 43526    public List<string> RequirePolicies { get; init; } = []; // Authorization policies, if any
 27    /// <summary>
 28    /// Name of the CORS policy to apply, if any.
 29    /// </summary>
 37730    public string CorsPolicy { get; set; } = string.Empty; // Name of the CORS policy to apply, if any
 31    /// <summary>
 32    /// If true, short-circuits the pipeline after this route.
 33    /// </summary>
 5934    public bool ShortCircuit { get; set; } // If true, short-circuit the pipeline after this route
 35    /// <summary>
 36    /// Status code to return if short-circuiting the pipeline after this route.
 37    /// </summary>
 838    public int? ShortCircuitStatusCode { get; set; } = null; // Status code to return if short-circuiting
 39    /// <summary>
 40    /// If true, allows anonymous access to this route.
 41    /// </summary>
 6342    public bool AllowAnonymous { get; set; }
 43    /// <summary>
 44    /// If true, disables antiforgery protection for this route.
 45    /// </summary>
 8846    public bool DisableAntiforgery { get; set; }
 47    /// <summary>
 48    /// If true, disables response compression for this route.
 49    /// </summary>
 5650    public bool DisableResponseCompression { get; set; }
 51    /// <summary>
 52    /// The name of the rate limit policy to apply to this route, if any.
 53    /// </summary>
 5854    public string? RateLimitPolicyName { get; set; }
 55    /// <summary>
 56    /// Endpoints to bind the route to, if any.
 57    /// </summary>
 38158    public string[]? Endpoints { get; set; } = [];
 59
 60    /// <summary>
 61    /// Default response content type for this route.
 62    /// </summary>
 10863    public IDictionary<string, ICollection<ContentTypeWithSchema>>? DefaultResponseContentType { get; set; }
 64
 65    /// <summary>
 66    /// Content types that this route can consume, if any.
 67    /// </summary>
 35768    public List<string> AllowedRequestContentTypes { get; set; } = [];
 69
 70    /// <summary>
 71    /// OpenAPI metadata for this route.
 72    /// </summary>
 40273    public Dictionary<HttpVerb, OpenAPIPathMetadata> OpenAPI { get; set; } = []; // OpenAPI metadata for this route
 74
 75    /// <summary>
 76    /// Indicates whether this route originated from an OpenAPI-annotated function definition.
 77    /// </summary>
 2878    public bool IsOpenApiAnnotatedFunctionRoute { get; set; }
 79
 80    /// <summary>
 81    /// Path-level OpenAPI common metadata for this route.
 82    /// </summary>
 983    public OpenAPICommonMetadata? PathLevelOpenAPIMetadata { get; set; }
 84
 85    /// <summary>
 86    /// Script code and language options for this route.
 87    /// </summary>
 72888    public LanguageOptions ScriptCode { get; init; } = new LanguageOptions();
 89    /// <summary>
 90    /// Best-effort handler identity for the route when a named source is available.
 91    /// </summary>
 1692    public string? HandlerName { get; set; }
 93    /// <summary>
 94    /// If true, throws an exception on duplicate routes.
 95    /// </summary>
 1596    public bool ThrowOnDuplicate { get; set; }
 97
 98    /// <summary>
 99    /// Callback requests associated with this route.
 100    /// </summary>
 316101    public List<CallbackPlan> CallbackPlan { get; set; } = [];
 102
 103    /// <summary>
 104    /// Form parsing options for this route, if any.
 105    /// </summary>
 8106    public KrFormOptions? FormOptions { get; set; }
 107
 108    /// <summary>
 109    /// Returns a string representation of the MapRouteOptions.
 110    /// </summary>
 111    /// <returns></returns>
 112    public override string ToString()
 113    {
 1114        var verbs = HttpVerbs.Count > 0 ? string.Join(",", HttpVerbs) : "ANY";
 1115        return $"{verbs} {Pattern}";
 116    }
 117
 118    /// <summary>
 119    /// Adds security requirement information to this route's authorization settings.
 120    /// </summary>
 121    /// <param name="schemes">the authorization schemes required for this route</param>
 122    /// <param name="policies">the authorization policies required for this route</param>
 123    public void AddSecurityRequirementObject(List<string>? schemes, List<string>? policies)
 124    {
 0125        if (schemes is { Count: > 0 })
 126        {
 0127            RequireSchemes.AddRange(schemes);
 128        }
 129
 0130        if (policies is { Count: > 0 })
 131        {
 0132            RequirePolicies.AddRange(policies);
 133        }
 0134    }
 135}