public Task Handle(IHttpContext context, Func <Task> next) { foreach (var route in _routes) { var matchingResult = route.Condition.Match(context); if (matchingResult.IsMatch) { var subContext = context.Dive(matchingResult); return(route.Handler.Handle(subContext, next)); } } // Route not found, call next and thereby reverse dive return(next()); }