https://github.com/longkai/rfc7807
The Go implementation of Problem Details for HTTP APIs, defined in https://tools.ietf.org/html/rfc7807
https://github.com/longkai/rfc7807
Last synced: 6 months ago
JSON representation
The Go implementation of Problem Details for HTTP APIs, defined in https://tools.ietf.org/html/rfc7807
- Host: GitHub
- URL: https://github.com/longkai/rfc7807
- Owner: longkai
- License: mit
- Created: 2019-08-24T07:15:48.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-01T14:54:03.000Z (over 4 years ago)
- Last Synced: 2024-06-21T16:47:20.074Z (about 2 years ago)
- Language: Go
- Size: 18.6 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RFC 7807
[](http://godoc.org/github.com/longkai/rfc7807)
Package rfc7807 implements RFC 7807, Problem Details for HTTP APIs:
https://tools.ietf.org/html/rfc7807.
This package predefined Google's gRPC canonical error codes:
https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto.
To create a new problem detail:
rfc7807.New(rfc7807.NotFound, "xxx is not found.")
Or wrap with a underlying error:
rfc7807.Wrap(rfc7807.Internal, "", causeError)
It supports Go 2 error as values proposal:
https://go.googlesource.com/proposal/+/master/design/29934-error-values.md.
If the predefined errors doesn't satisfy your needs:
rfc7807.Customize("my.error.domain", "MY_ERROR_TYPE", 400, nil, nil)
### Install
`go get github.com/longkai/rfc7807`