When dealing with a request we use IApplicationBuilder. And we have four methods available to interact with a request:
- Use
- Run
- Map
- MapWhen
These are called Request Delegates.
Use:
Adds a middleware to the application pipeline and it can either pass the request to next delegate or it can end the request (short- circuit request pipeline). It is the most commonly used method to interact with middleware.
More simple (app.use
inserts a middleware into the pipeline which requires you to call the next middleware by calling next.Invoke()).
Run:
app.run
inserts a middleware without a next, so it just runs.
Map:
With app.map
you can map paths, which get evaluated at runtime, per request, to run certain middleware only if the request path matches the pattern you mapped.
MapWhen:
Behaves almost the same as Map except that we can specify the detailed condition by using a HttpContext object. We could check for URL, headers, query strings, cookies, etc).
Thank you
No comments:
Post a Comment