public async Task InvokeAsync(HttpContext httpContext, Func <Task> next) { var start = DateTime.Now; Route route = null; try { route = (Route)router.TryFindRoute(httpContext.Request); if (route != null) { var message = await this.messageDeserializer.DeserializeMessageAsync <IMessage>(httpContext.Request, route); var response = await messageBus.ExecuteAsync(message); await responseWriter.WriteResponseAsync(response, httpContext.Response); } else { throw new RouteNotFoundException(httpContext); } } catch (Exception exception) { await errorBus.HandleAsync(exception); await errorWriter.WriteErrorAsync(exception, httpContext.Response); } var trace = new HttpTrace(httpContext, start, DateTime.Now); await tracer.Trace(trace); // next if route not found ? //if (route == null) // await next(); }