Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Created May 13, 2018 15:30
Show Gist options
  • Select an option

  • Save PradeepLoganathan/82b27140ad6d95fe5615f4bf151f4286 to your computer and use it in GitHub Desktop.

Select an option

Save PradeepLoganathan/82b27140ad6d95fe5615f4bf151f4286 to your computer and use it in GitHub Desktop.
Creating a middleware pipeline with map
app.Use(async (context, next) =>
{
await context.Response.WriteAsync("Middleware One</br>");
await next.Invoke();
});
app.Use(async (context, next) =>
{
await context.Response.WriteAsync("Middleware Two</br>");
await next.Invoke();
});
app.Use(async (context, next) =>
{
await context.Response.WriteAsync("Middleware Three</br>");
await next.Invoke();
});
app.Map("/branch1", (appBuilder) =>
{
appBuilder.Use(async (context, next) =>
{
await context.Response.WriteAsync("--Branch 1 - Middleware One</br>");
await next.Invoke();
});
appBuilder.Use(async (context, next) =>
{
await context.Response.WriteAsync("--Branch 2 - Middleware Two</br>");
await next.Invoke();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment