I find it quite confusing what exactly are the differences in using Flask's before_request() and/or after_request() versus using a WSGI middleware.
Say I want to do something very silly like this:
- Every request-body should be scanned for the word "bacon" and be replaced with "eggs".
- Now request hits flask-view (according to url-mapping), view-function creates the response
- Every response-body should be scanned for "eggs" and replaced with "bacon"
Would I use a WSGI middleware or the Flask functions? Coming from django with a very robust middleware suite, the difference is not clear to me.
Thanks in advance. berni