Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

MapMiddleware should support rejoining the parent pipeline #351

Closed
davidfowl opened this issue Jul 19, 2015 · 8 comments
Closed

MapMiddleware should support rejoining the parent pipeline #351

davidfowl opened this issue Jul 19, 2015 · 8 comments

Comments

@davidfowl
Copy link
Member

Right now the MapMiddleware either takes the branch or calls next. There should be an option to fallback to the parent pipeline (or maybe that should just be the default), instead of getting a child appbuilder with a 404 by default.

/cc @Tratcher @DamianEdwards

@muratg muratg added this to the 1.0.0 Backlog milestone Jul 20, 2015
@muratg
Copy link

muratg commented Jul 20, 2015

Sounds like a good idea. 1.0.0 backlog for now.

@Tratcher
Copy link
Member

We've theorized about this since the first days of Katana, but nobody has ever actually asked for it.

I think you'd want it to be a distinct keyword rather than just an option because of how much it changes the semantics.

@avanderhoorn
Copy link
Member

I have a use case for this. We want to have app.Map("/Glimpse", ...) which dynamically loads various "child" middleware. If none of these deal with the request, I want it to continue on with the users pipeline, we shouldn't steal everything that is under Glimpse.

@avanderhoorn
Copy link
Member

With help from @davidfowl, I've done up the following based on the current app.Map() implementation - https://gist.github.com/avanderhoorn/00de3272901797060812

@Bartmax
Copy link

Bartmax commented Sep 23, 2015

👍

In my case, I have an Authorization Server and Resource Server on same project.
I want all my api calls to be excluded from Identity middleware while other routes uses Identity. something like:

  public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();

            app.UseOAuthBearerAuthentication(opt =>
            {
                opt.AutomaticAuthentication = true;
            });

            app.MapWhen(ctx => !ctx.Request.Path.StartsWithSegments(new PathString("/api")), (subApp) =>
            {
                subApp.UseIdentity();
            });

            // right now, the following lines won't get called if the request doesn't start with the /api path.
            // I would expect to have some kind of (if something do this and continue with the other stuff outside the condition. Like an if flow.
            app.UseMvc();
            ...
        }

@darrelmiller
Copy link

Seems to me that something like that should be called app.UseWhen(...) It is just a piece of regular middleware that only applies to a subset of the URI space.

@tuespetre
Copy link
Contributor

👍

Another use case would be to only call 'error-handling' middleware like app.UseDeveloperExceptionPage() and app.UseStatusCodePagesWithReExecute("/Error/{0}") if the request is not an AJAX request.

@kevinchalet
Copy link
Contributor

FWIW, here's the UseWhen version I'm using for a year now: https://gist.github.com/PinpointTownes/6d0492cd3d1b3a64a670

@Tratcher Tratcher modified the milestones: 1.1.0, Backlog Jul 5, 2016
@Tratcher Tratcher closed this as completed Jul 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants