10
I’m studying the OWIN and its implementation Katana by Microsoft. I’ve asked about it here and the answers already help to have a good overview of the subject. Going deeper I found this doubt. In the specification are proposed two pro functioning objects of everything: the Dictionary Environment and the delegate application.
From what I understand the intuition behind this is the following: Environment Dictionary has all the HTTP request and response data. The application delegate, on the other hand, is a pointer to a function that receives the Environment Dictionary and returns a Task. Thus, the application delegate, from what I understand receives the Dictionary Environment with the request data, and is able to modify the response asynchronously.
So far so good. My doubt is that there are middleware. From what I understand the middleware are basically components that we can plug into the pipeline and that are able to interfere with the request by modifying the answer. For example the Cookie Authentication Middleware can be plugged into the pipeline and manipulates the response to implement cookie authentication. Similarly, we can plug in the Webapi that is capable of handling the request and provide the functionality of a Restful service.
Basically, there seems to be a very close relationship between middleware and application delegate. My doubt, in fact, is the following: by application built on top of the OWIN exists only one application delegate or several working together? In that case how does application delegate relate to middleware?
I imagine it is as follows: there is an application delegate per application and when we use the extension method Use
to add a middleware basically what happens is that the Invoke
of middleware is added to the delegate. In this way, the delegate application can perform all the tasks in sequence, one of each middleware, allowing each middleware to handle the request one after the other in the record sequence. That’s the way it works?