resty
resty copied to clipboard
Allow OnAfterResponse ResponseMiddleware to run on all paths
As of now, custom response middlewares are only executed on the happy path of a request (that is, no error and with notParseResponse == false
due to them being in the same list as the internal Resty middlewares for response handling
It is desirable that the user defined middlewares are executed on all paths and let the response handling to the user (as user defined request middlewares work now)
Due to middlewares cannot run on all paths, I have to design a new Middleware layer base on Wrapping Transport. QAQ
@lggomez I believe you're referring to response middlewares correct? If so what is the behavior you're trying to propose, do you mind showcasing via PR?
Yes. The work involved is similar to #355, plus a separation of afterResponse
and udAfterResponse
so that OnAfterRequest middlewares behave exactly that the OnBefore ones, internal ones first and client defined after
Now that you solved the ci issue (thanks!) I was hoping to take a shot at this soon
@lggomez You're welcome, it was a config issue with Travis build.
Resty's middleware behavior (typically it should) will halt the execution at middleware which had an error regardless of internal or user-defined middleware.
#355 is different (thanks again for submitting PR). I'm trying to understand the design & approach of "run on all paths", could you please describe?
I think "run on all paths" meas that afterResponse middlewares will be execute whether the request and beforeRequest middlewares are done successfully or not
It is as @zhong-wx says, I layed out the initial implementation on the linked PR
There is a middleware redesign coming in v3, so Resty users get to choose the middleware execution and its order. Plus this issue suggestion I will consider applying this on default flow.