web icon indicating copy to clipboard operation
web copied to clipboard

Post Body is Empty

Open paulbellamy opened this issue 13 years ago • 1 comments

It seems like web.go automatically processes the body of all POSTs as a form, which unfortunately leaves the body empty. For PUT (and other, I assume) requests it leaves the body intact, so it is possible to receive JSON that way. However it would be really helpful to be able to parse POST data as JSON (i.e. for building RESTful apps). Is there a way to have web.go leave the body intact after parsing the params?

Thanks!

paulbellamy avatar Mar 17 '11 23:03 paulbellamy

Not sure when this was added or if you're still watching, but if Content-Type is 'application/json', it copies the body data into Request.ParamData []byte. If you want an io.Reader, of course, you can use bytes.NewBuffer(request.ParamData).

awpr avatar Dec 18 '11 03:12 awpr