Created
May 13, 2018 15:30
-
-
Save PradeepLoganathan/82b27140ad6d95fe5615f4bf151f4286 to your computer and use it in GitHub Desktop.
Creating a middleware pipeline with map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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