public IResult Call(IServiceProvider services, RouteCallMatch match, HttpListenerContext context) { object route = _constructor.Construct(services); _contextSetDelegate?.Invoke(route, context); return((IResult)_delegate(route, match.Parameters)); }
public IResult Handle(IServiceProvider services, HttpListenerContext context) { var match = new RouteCallMatch(); foreach (var route in _routes) { if (match.TryMatch(route, context, ParamReplacer)) { var filterResult = route.Filters.Select(f => f.CreateAndInject(services).Filter(context)).FirstOrDefault(r => r != null); return(filterResult ?? route.Call(services, match, context)); } if (match.FatalError != null) { Logger.Default.Error("Router", $"Error while trying to match router request {context.Request.Url}:", match.FatalError); return(null); } } return(null); }