if you plan to respond directly to the client from pipepart1
, then you could avoid calling other middlewares in the pipeline. Following is an example. Is this something you had in mind?
Here based on some condition (in my case if querystring has a particular key), I decide to either respond directly to the client or call onto next middleware.
appBuilder.Map("/something/something", doit =>
{
doit.Use<Pipepart1>();
doit.Use<Pipepart2>();
});
public class Pipepart1 : OwinMiddleware
{
public Pipepart1(OwinMiddleware next) : base(next) { }
public override Task Invoke(IOwinContext context)
{
if (context.Request.Uri.Query.Contains("shortcircuit"))
{
return context.Response.WriteAsync("Hello from Pipepart1");
}
return Next.Invoke(context);
}
}
public class Pipepart2 : OwinMiddleware
{
public Pipepart2(OwinMiddleware next) : base(next) { }
public override Task Invoke(IOwinContext context)
{
return context.Response.WriteAsync("Hello from Pipepart2");
}
}