jsonapi

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 2 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Data   interface{} `json:"data,omitempty"`
	Errors Errors      `json:"errors,omitempty"`
	Meta   Meta        `json:"meta,omitempty"`
}

func BuildResponse

func BuildResponse(opts ...Option) *Body

func (*Body) HTTPStatus

func (b *Body) HTTPStatus() int

type Error

type Error struct {
	Title  string `json:"title,omitempty"`
	Detail string `json:"detail,omitempty"`
	Code   string `json:"code,omitempty"`
	Status int    `json:"status,omitempty"`
	Meta   Meta   `json:"meta,omitempty"`
}

func (Error) Error

func (e Error) Error() string

type Errors

type Errors []Error

func (Errors) Error

func (e Errors) Error() string

func (Errors) HTTPStatus

func (e Errors) HTTPStatus() int

type Meta

type Meta map[string]interface{}

type Option

type Option func(*Body)

func WithData

func WithData(data interface{}) Option

func WithErrors

func WithErrors(errors Errors) Option

func WithException

func WithException(code string, status int, exc exception.Exception) Option

func WithExceptionMeta

func WithExceptionMeta(code string, status int, exc exception.Exception, meta Meta) Option

func WithMeta

func WithMeta(key string, field interface{}) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL