As the name suggests, middleware is a piece of software that connects two different or similar places. In the world of software engineering, middleware is a software component and is assembled in an application pipeline to handle requests and responses.
These components can also check whether a request should pass to the next components, or whether the request should be handled by a component before or after the next component is triggered/invoked. This request pipeline is built with the use of a request delegate. This request delegate interacts with each HTTP request.
Look at the following quote from the documentation of ASP.NET Core (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/):
Look at the following diagram...