KestrunHostMapExtensions.GetMapRouteOptions method

Retrieves the MapRouteOptions associated with a given route pattern and HTTP verb, if registered.

public static MapRouteOptions? GetMapRouteOptions(this KestrunHost host, string pattern, 
    HttpVerb verb)
parameter description
host The KestrunHost instance to search for registered routes.
pattern The route pattern to look up (e.g. "/hello").
verb The HTTP verb to match (e.g. Get).

Return Value

The MapRouteOptions instance for the specified route if found; otherwise, null.

Remarks

This method checks the internal route registry and returns the route options if the pattern and verb combination was previously added via AddMapRoute. This lookup is case-insensitive for both the pattern and method.

Examples

var options = host.GetMapRouteOptions("/hello", HttpVerb.Get);
if (options != null)
{
    Console.WriteLine($"Route language: {options.Language}");
}

See Also