A optioned REST response encoder compatible with Go's standard lib.
go get github.com/caiorcferreira/restencoder
restencoder.Respond(
w,
StatusCode(http.StatusCreated),
Header("X-Header", "value"),
JSONBody(body),
)
restencoder.Respond(
w,
StatusCode(http.StatusBadRequest),
Header("X-Header", "value"),
Error(err),
)
If you want a different failure response schema, you could implement your own restencoder.ResponseOption
to define ResponseConfig.JSONBody
to your failure response struct.
Every help is always welcome. Feel free do throw us a pull request, we'll do our best to check it out as soon as possible. But before that, let us establish some guidelines:
- This is an open source project so please do not add any proprietary code or infringe any copyright of any sort.
- Avoid unnecessary dependencies or messing up go.mod file.
- Be aware of golang coding style. Use a lint to help you out.
- Add tests to cover your contribution.
- Use meaningful messages to your commits.
- Use pull requests.
- At last, but also important, be kind and polite with the community.
Any submitted issue which disrespect one or more guidelines above, will be discarded and closed.
Released under the MIT License.