Exemplo n.º 1
0
        // Awaited fallbacks for when the Tasks do not synchronously complete
        static async Task AwaitMatcher(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task <Matcher> matcherTask)
        {
            var matcher = await matcherTask;
            await matcher.MatchAsync(httpContext);

            await middleware.SetRoutingAndContinue(httpContext);
        }
    private EndpointRoutingMiddleware CreateMiddleware(
        Logger <EndpointRoutingMiddleware> logger = null,
        MatcherFactory matcherFactory             = null,
        DiagnosticListener listener = null,
        RequestDelegate next        = null)
    {
        next ??= c => Task.CompletedTask;
        logger ??= new Logger <EndpointRoutingMiddleware>(NullLoggerFactory.Instance);
        matcherFactory ??= new TestMatcherFactory(true);
        listener ??= new DiagnosticListener("Microsoft.AspNetCore");

        var middleware = new EndpointRoutingMiddleware(
            matcherFactory,
            logger,
            new DefaultEndpointRouteBuilder(Mock.Of <IApplicationBuilder>()),
            listener,
            next);

        return(middleware);
    }
Exemplo n.º 3
0
 static async Task AwaitMatch(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
 {
     await matchTask;
     await middleware.SetRoutingAndContinue(httpContext);
 }