EPIC: Rewrite the MVC Dispatcher
With the introduction of the PSR-15 middlewares (#1928 and #2019) we cover the whole HTTP dispatch process in a standard and extendable way. At the inner core of this middleware process is currently the MVC dispatcher, which is responsible to convert an Http request to an ActionRequest, resolving a Controller, dispatching the ActionRequest to that Controller and receiving or wrapping the action return value in an ActionResponse, which is then converted into an Http Response that is further piped through the PSR-15 middlewares.
The ActionRequest and ActionResponse abstractions give a nice high level abstraction of the underlying http messages, but currently it's not possible to interact with those in a cross-cutting concern other than inside the controller. Also, the MVC dispatcher currently holds a couple of responsibilities (resolving controller, looping the dispatch attempts, handling authentication errors, etc.). Therefore it might be benefitial to split the dispatcher into another middleware layer that acts upon an ActionRequest and an ActionResponse.
Related / Todos:
- [ ] https://github.com/neos/flow-development-collection/issues/1305
- [ ] Maybe? https://github.com/neos/flow-development-collection/issues/1233
- [ ] https://github.com/neos/flow-development-collection/issues/3291
- [ ] Move firewall out as middleware
- [ ] https://github.com/neos/flow-development-collection/pull/3232
/cc @sorenmalling
The firewall is also handled inside the Dispatcher. This could be moved out as a middleware in such a iteration
Assigned @albe and myself to hold os accountable on the other side of the Flow 7.0 release :)
One idea: Let's move the currently deprecated Http\Headers class into the Mvc namespace and make it part of the ActionResponse API in order to specify headers to set in the response, instead of the SetHeaderComponent parameter currently.
The idea is that ActionResponse is a higher level abstraction of a response and Headers is a (slightly) higher level abstraction of basic Http headers that hides some details like the Cache-Control stuff. Also we need a replacement for the SetHeaderComponent and just moving that to a middleware that still needs to fetch the specified headers from some global context feels weird. With the Headers inside the ActionResponse, the MVC Dispatcher can translate the ActionResponse into a HTTP Response with headers, which is more straightforward.
We could even do this right now already.
Related https://github.com/neos/flow-development-collection/pull/2219 resp. https://github.com/neos/flow-development-collection/pull/2219/commits/aeb132d53c6ea818ff603a8108d36db4b60468c8 - reverting this commit could be a basis for re-adding the Headers class into the ActionResponse
Ill move the Headers related discussion over here: https://github.com/neos/flow-development-collection/issues/3291
Thanks for all the crumbles you left me. Today i was quite the detective :D