< 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@eeafbe813231ed23417e7b339e170e307b2c86f9
Line coverage
78%
Covered lines: 22
Uncovered lines: 6
Coverable lines: 28
Total lines: 131
Line coverage: 78.5%
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 09/12/2025 - 13:32:05 Line coverage: 100% (22/22) Total lines: 110 Tag: Kestrun/Kestrun@63ea5841fe73fd164406accba17a956e8c08357f10/13/2025 - 16:52:37 Line coverage: 100% (15/15) Total lines: 72 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e12/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@bf8a937cfb7e8936c225b9df4608f8ddd85558b1 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@bf8a937cfb7e8936c225b9df4608f8ddd85558b1

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>
 61514    public string? Pattern { get; set; }
 15    /// <summary>
 16    /// The HTTP verbs (methods) that this route responds to.
 17    /// </summary>
 70118    public List<HttpVerb> HttpVerbs { get; set; } = [];
 19    /// <summary>
 20    /// Authorization Scheme names required for this route.
 21    /// </summary>
 36722    public List<string> RequireSchemes { get; init; } = []; // Authorization scheme name, if any
 23    /// <summary>
 24    /// Authorization policy names required for this route.
 25    /// </summary>
 35126    public List<string> RequirePolicies { get; init; } = []; // Authorization policies, if any
 27    /// <summary>
 28    /// Name of the CORS policy to apply, if any.
 29    /// </summary>
 30730    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>
 4334    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>
 4142    public bool AllowAnonymous { get; set; }
 43    /// <summary>
 44    /// If true, disables antiforgery protection for this route.
 45    /// </summary>
 6646    public bool DisableAntiforgery { get; set; }
 47    /// <summary>
 48    /// If true, disables response compression for this route.
 49    /// </summary>
 4050    public bool DisableResponseCompression { get; set; }
 51    /// <summary>
 52    /// The name of the rate limit policy to apply to this route, if any.
 53    /// </summary>
 4254    public string? RateLimitPolicyName { get; set; }
 55    /// <summary>
 56    /// Endpoints to bind the route to, if any.
 57    /// </summary>
 31858    public string[]? Endpoints { get; set; } = [];
 59
 60    /// <summary>
 61    /// Default response content type for this route.
 62    /// </summary>
 8163    public IDictionary<string, ICollection<ContentTypeWithSchema>>? DefaultResponseContentType { get; set; }
 64
 65    /// <summary>
 66    /// Content types that this route can consume, if any.
 67    /// </summary>
 28068    public List<string> AllowedRequestContentTypes { get; set; } = [];
 69
 70    /// <summary>
 71    /// OpenAPI metadata for this route.
 72    /// </summary>
 31473    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>
 1478    public bool IsOpenApiAnnotatedFunctionRoute { get; set; }
 79
 80    /// <summary>
 81    /// Path-level OpenAPI common metadata for this route.
 82    /// </summary>
 283    public OpenAPICommonMetadata? PathLevelOpenAPIMetadata { get; set; }
 84
 85    /// <summary>
 86    /// Script code and language options for this route.
 87    /// </summary>
 58188    public LanguageOptions ScriptCode { get; init; } = new LanguageOptions();
 89    /// <summary>
 90    /// If true, throws an exception on duplicate routes.
 91    /// </summary>
 1292    public bool ThrowOnDuplicate { get; set; }
 93
 94    /// <summary>
 95    /// Callback requests associated with this route.
 96    /// </summary>
 26797    public List<CallbackPlan> CallbackPlan { get; set; } = [];
 98
 99    /// <summary>
 100    /// Form parsing options for this route, if any.
 101    /// </summary>
 0102    public KrFormOptions? FormOptions { get; set; }
 103
 104    /// <summary>
 105    /// Returns a string representation of the MapRouteOptions.
 106    /// </summary>
 107    /// <returns></returns>
 108    public override string ToString()
 109    {
 1110        var verbs = HttpVerbs.Count > 0 ? string.Join(",", HttpVerbs) : "ANY";
 1111        return $"{verbs} {Pattern}";
 112    }
 113
 114    /// <summary>
 115    /// Adds security requirement information to this route's authorization settings.
 116    /// </summary>
 117    /// <param name="schemes">the authorization schemes required for this route</param>
 118    /// <param name="policies">the authorization policies required for this route</param>
 119    public void AddSecurityRequirementObject(List<string>? schemes, List<string>? policies)
 120    {
 0121        if (schemes is { Count: > 0 })
 122        {
 0123            RequireSchemes.AddRange(schemes);
 124        }
 125
 0126        if (policies is { Count: > 0 })
 127        {
 0128            RequirePolicies.AddRange(policies);
 129        }
 0130    }
 131}