Skip to content

Issue Parsing x-www-form-urlencoded POST Requests #50

@antsankov

Description

@antsankov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions