0

I know that at the middleware level the concept of "request" doesn't exist yet because the request object hasn't been initialized.

However, I find it very helpful if I can dump request.data in the middleware layer so I don't have to liter pprint(request.data) all over my application file.

Can someone tell me a way to do this at the middle layer level?

Tinker
  • 4,165
  • 6
  • 33
  • 72
  • Take into account that the wsgi.input reference is a *file object*, you may want to seek back to 0 before passing on the WSGI environment to the next layer. – Martijn Pieters May 22 '16 at 22:01
  • @MartijnPieters I tried `environ['wsgi.input'].seek(0)` I am getting a `IOError: [Errno 29] Illegal seek` – Tinker May 22 '16 at 23:16
  • It depend on the WSGI server wether that is available. I guess you could replace that object with a `io.BytesIO` object with the full contents from a read from the old object. Only do that when the seek fails. – Martijn Pieters May 23 '16 at 00:08

0 Answers0