[99s-extend] Using cowboy_req:body more than once per request

Paulo F. Oliveira paulo.ferraz.oliveira at gmail.com
Tue Sep 16 00:35:20 CEST 2014


Hi.

> It seems a bit weird to me to read the body and validate it before validating the request itself.

It certainly seems like it, but I had no immediate solution and
instead of changing a dozen handlers, this seemed faster to implement
:D. I don't understand what you mean by "validating the request
itself". I read the header (I mentioned previously) and the body and
check one against the other. They are present and enough for the
_validator_ to make a decision, but I might be missing something here.

> I would explicitly put these checks in the handler directly. This of course means that there is no need to read it twice anymore.

I've been trying to find a way to easily share code between handlers
without having to rewrite a lot of code (even if I do decide to put
things in a library function - or several). I recently came across
https://github.com/opscode/mixer. Have you ever used it?

Thanks.

- Paulo F. Oliveira


More information about the Extend mailing list