Middleware is a layer, software, or simple class through which all the requests and responses have to go through. The middleware is assembled of many delegates in an application pipeline. Each component(delegate) in the pipeline of the middleware decides :
- To pass the request to the next component.
- Perform some processing on the request before or after passing it.
The below diagram shows a middleware request pipeline consisting of many delegates called one after another. Where black arrows mark the direction of execution. Each delegate in the diagram performs some operations before or after the next delegate.
More details from Microsoft’s documentation.