Closed higoka closed 6 years ago
$handler->handle($req);
is being called before your Stream#write()
operation, so that's why the order is completely messed up.
Move the write()
call to the first operation in each middleware.
Dont know exactly what you mean, can you show?
Ah, I see where the confusion is: the $response
is indeed produced in the inner-most middleware, so it cannot be written upon before passing to the next layer.
I'm re-writing your example by modifying $request
instead:
https://gist.github.com/Ocramius/2fe892d36c54811e0cb60ba9b5db5c29
Ah, now i see. Thanks for clarification.
@higoka :+1:
I was testing around with stratigility and in the docs it says the middleware execution order is FIFO. But in reality is LIFO.
I created a gist with the example im using: https://gist.github.com/higoka/78f875ad30a8c61127b61c8b4cffb0f7
The result i get is: 3 2 1 But with FIFO i would expect: 1 2 3