go-rest
go-rest copied to clipboard
Issue Parsing x-www-form-urlencoded POST Requests
I was working on an endpoint that needed to receive requests in the format x-www-form-urlencoded. This causes issues with the JSON decoder line in handler.go:
data, err := decodePayload(payloadString(r.Body))
if err != nil {
// Payload decoding failed.
ctx = ctx.setError(BadRequest(err.Error()))
}
Obviously if the data isn't in JSON format it can't be decoded. However if you even attempt to decode r.Body, because it is a io stream, it is emptied and can't be accessed.
I devised a way of fixing this in my project, and was curious if there was any interest in a pull request for this issue.