Closed luceos closed 4 years ago
Replace, Add and Remove are all function that should work using the current middleware dependency (pipe) however the insertAfter
and insertBefore
may not work exactly as intended because the middleware pipe is Asynchronous so although it may sometimes work in the order that we place the middlewares it may also not sometimes if a middleware takes longer to process than others.
Replace, Add and Remove are all function that should work using the current middleware dependency (pipe)
Hmm, I thought that was not possible, judging by the MiddlewarePipe
class' implementation:
The function is not built in no, but if we manipulate the middleware array before finalization it is possible as noted in the original ticket:
In order to do so we will bind the middleware stack (array) into IoC and resolve it for the pipeline.
It can be done
Oh, yes. Okay, misunderstanding cleared then.
We first have to bind the array to the container, manipulate that via extenders, and only wrap it in the pipe when we actually have a request that needs to be handled.
Based on work done in #1919 we now need to be able to mutate the middleware stack before it is finalised. In order to do so we will bind the middleware stack (array) into IoC and resolve it for the pipeline.
The methods we need to allow for are at least:
insertAfter
insertBefore
replace
add
remove
Then when we use the Middleware extender, we can allow direct mutation of this stack as well. An example would be:
Or similar using the extender:
One could possibly use the magic methods to proxy the method to the stack.