Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ddymko/go-jsonerror
Small package which wraps error responses to follow jsonapi.org
https://github.com/ddymko/go-jsonerror
go golang-json json-api json-error jsonapi-spec
Last synced: about 1 month ago
JSON representation
Small package which wraps error responses to follow jsonapi.org
- Host: GitHub
- URL: https://github.com/ddymko/go-jsonerror
- Owner: ddymko
- License: mit
- Created: 2018-10-18T15:03:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-09T11:56:05.000Z (over 4 years ago)
- Last Synced: 2024-01-30T04:49:23.385Z (4 months ago)
- Topics: go, golang-json, json-api, json-error, jsonapi-spec
- Language: Go
- Size: 17.6 KB
- Stars: 14
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-go - go-jsonerror - Go-JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go-extra - go-jsonerror - 10-18T15:03:45Z|2019-10-09T11:56:05Z| (JSON / Advanced Console UIs)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go-projects - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Standard CLI)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Advanced Console UIs)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go-cn - go-jsonerror - JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec. [![近三年未更新][Y]](https://github.com/ddymko/go-jsonerror) [![godoc][D]](https://godoc.org/github.com/ddymko/go-jsonerror) (JSON / 检索及分析资料库)
- go-awesome-cn-star - go-jsonerror - JsonError`的目的是让我们能够轻松创建遵循`JsonApi`规范的`json`响应错误。(12) (JSON / SQL 查询语句构建库)
- awesome-go-stars - go-jsonerror(stars: 15) - Go-JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go-with-stars - go-jsonerror - Go-JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Advanced Console UIs)
- repo-1316-awesome-go-cn - go-jsonerror - JsonError允许我们轻松创建符合JsonApi规范的json响应错误。 [![近三年未更新][Y]](https://github.com/ddymko/go-jsonerror) [![godoc][D]](https://godoc.org/github.com/ddymko/go-jsonerror) (JSON / 检索及分析资料库)
- repo-1211-awesome-go-cn - go-jsonerror - JsonError允许我们轻松创建符合JsonApi规范的json响应错误。 [![近三年未更新][Y]](https://github.com/ddymko/go-jsonerror) [![godoc][D]](https://godoc.org/github.com/ddymko/go-jsonerror) (JSON / 检索及分析资料库)
- awesome-Char - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Advanced Console UIs)
- awesome-reader - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Advanced Console UIs)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Advanced Console UIs)
- Go-awesome - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go-cn - go-jsonerror - JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec. [![近三年未更新][Y]](https://github.com/ddymko/go-jsonerror) [![godoc][D]](https://godoc.org/github.com/ddymko/go-jsonerror) (JSON / 检索及分析资料库)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Advanced Console UIs)
- awesome-go - go-jsonerror - Go-JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go - go-jsonerror - Go-JsonError is ment to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Advanced Console UIs)
- awesome-go-cn - go-jsonerror - JsonError允许我们轻松创建符合JsonApi规范的json响应错误。 (JSON / 高级控制台用户界面)
- awesome-go-zh - go-jsonerror - JsonError允许我们轻松创建符合JsonApi规范的json响应错误。 [![godoc][D]](https://godoc.org/github.com/ddymko/go-jsonerror) (JSON / 检索及分析资料库)
- awesome-go-cn - go-jsonerror - JsonError`的目的是让我们能够轻松创建遵循`JsonApi`规范的`json`响应错误。 (JSON / SQL 查询语句构建库)
- awesome-go - go-jsonerror - Go-JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
- awesome-go - go-jsonerror - Go-JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec. (JSON / Search and Analytic Databases)
README
# Go-JsonError
[![Go Report Card](https://goreportcard.com/badge/github.com/ddymko/go-jsonerror)](https://goreportcard.com/report/github.com/ddymko/go-jsonerror) [![Build Status](https://travis-ci.org/ddymko/go-jsonerror.svg?branch=master)](https://travis-ci.org/ddymko/go-jsonerror) [![Coveragestatus](https://codecov.io/gh/ddymko/go-jsonerror/branch/master/graph/badge.svg)](https://codecov.io/github/ddymko/go-jsonerror?branch=master)
[![GoDoc](https://godoc.org/github.com/ddymko/go-jsonerror?status.svg)](https://godoc.org/github.com/ddymko/go-jsonerror)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)Go-JsonError is meant to allow us to easily create json response errors that follow the JsonApi spec.
[Json API Spec](https://jsonapi.org/format/#errors)
## Usuage
In order to use jsonError you will need to initliaze the ErrorJson struct. Then when you would like to add an error you must pass in a ErrorComp struct to the AddError().
This follows the jsonapi spec where the error response must return an array.
Here is a basic example
``` go
var err ErrorJSONerrorComposition := ErrorComp{
Detail: "this is a error message",
Code: "This is the code",
Source: Source{
Pointer: "/unit/tests",
},
Title: "Title Test",
Status: 200,
}err.AddError(errorComposition)
err.Error()
err.ErrorByte()
```## Running the tests
This package is just using the standard test packge included with go. You can run the test cases with
``` sh
go test ./...
```## Contributing
Please feel free to submit any pull requests.
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/ddymko/go-jsonerror/tags).
## Authors
* **David Dymko**
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details