Open kgriffs opened 5 years ago
Could you expand how would this would work? In particular:
on_success
?independent_middleware
flag?I guess the location of the call in the application would after the lines here
If the objective is to support mainly the last point, maybe it would be simpler to detach if from the middleware, and have something similar to the add_error_handler
, something like a add_success_handler
or similar, that accepts a single function that could return a custom response to the server. I'm not sure if we should accept multiple functions, that are called one after the other, in order, where the first that returns a custom response would "win" and the processing of the other function would end, along with the processing of the rest of the application.
Something like
for handler in self._success_handlers:
body= handler(req, res, ...) # what other parameters should be pass?
if body is not None:
return body
@kgriffs @CaselIT Is it the same issue as https://github.com/falconry/falcon/issues/1505, or is the intent different here?
I had not seen the other one, and I'm not sure what the objective of this should be, so the questions.
Seems like it is similar to the other issue, but I don't want to lose the points brought up in the above discussion.
Implement an additional
on_finalize()
middleware method for ASGI and WSGI that is called immediately before the response body is returned to the server. This can be used by apps to implement protocol extensions (e.g., server push).