ninenines/cowboy

Unget body_qs -- is it possible?

Closed this issue · 5 comments

dvv commented

Here we explore possibility of building a middleware which takes decision based on content of request body. Seems no way to "unget" the body so that next middlewares can read it.

What could be a workaround or middleware technique doesn't apply here at all?

You can always set the body back on the buffer. But I don't recommend manipulating the body at all, the request should contain everything you need instead.

dvv commented

Hmm. I don't see means to set the buffer -- AFAICS it gets resetted after transfer_decode is called.
How do you mean request should contain everything? A CSRF token in querystring, no?

You have the cowboy_req:set(buffer, Buffer) function available.

Closing, thanks!

dvv commented

Thank you for the pointers