Is there a way to pass IOptions into a custom IRouteConstraint? I'm trying to check an appsetting to see if I need to have a certain route or not.
Can't find any references in the moment, but
HttpContext
, which is passed to the Match
methodExample:
public class MyConstraint : IRouteConstraint
{
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
{
var options = httpContext.RequestServices.GetService<IOptions<MySettings>>();
return ...;
}
}