response

package
v0.0.0-...-2eb6bad Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMetaCode

func BuildMetaCode(mainCode, subCode int) int

func IsAPIError

func IsAPIError(err error) bool

func RespError

func RespError(c *gin.Context, err APIError)

func RespOK

func RespOK(c *gin.Context, ok APIOK)

RespOK use jsoniter serialize

Types

type APIError

type APIError interface {
	MainCode() int
	SubCode() int
	Type() string
	Message() string
	Error() string
}

func NewBadRequestError

func NewBadRequestError(subCode int, err error) APIError

400

func NewConflictError

func NewConflictError(subCode int, err error) APIError

409

func NewForbiddenError

func NewForbiddenError(subCode int, err error) APIError

403 Forbidden

func NewInternalError

func NewInternalError(subCode int, err error) APIError

500

func NewNotFoundError

func NewNotFoundError(subCode int, err error) APIError

404

func NewServiceUnavailableError

func NewServiceUnavailableError(subCode int, err error) APIError

503

func NewUnauthorizedError

func NewUnauthorizedError(subCode int, err error) APIError

401 Unauthorized

func NewUnprocessableEntityError

func NewUnprocessableEntityError(subCode int, err error) APIError

422

type APIOK

type APIOK interface {
	MainCode() int
	SubCode() int
	Type() string
	Message() string
	Data() interface{}
}

func NewOK

func NewOK(data interface{}) APIOK

type BaseAPIError

type BaseAPIError struct {
	// contains filtered or unexported fields
}

func (*BaseAPIError) Error

func (c *BaseAPIError) Error() string

func (*BaseAPIError) MainCode

func (c *BaseAPIError) MainCode() int

func (*BaseAPIError) Message

func (c *BaseAPIError) Message() string

func (*BaseAPIError) SubCode

func (c *BaseAPIError) SubCode() int

func (*BaseAPIError) Type

func (c *BaseAPIError) Type() string

type OK

type OK struct {
	// contains filtered or unexported fields
}

func (*OK) Data

func (c *OK) Data() interface{}

func (*OK) Error

func (c *OK) Error() string

func (*OK) MainCode

func (c *OK) MainCode() int

func (*OK) Message

func (c *OK) Message() string

func (*OK) SubCode

func (c *OK) SubCode() int

func (*OK) Type

func (c *OK) Type() string

type RespBody

type RespBody struct {
	Meta RespMeta    `json:"meta"`
	Data interface{} `json:"data"`
}

type RespMeta

type RespMeta struct {
	Code    int           `json:"code"`
	Type    string        `json:"type,omitempty"`
	Message string        `json:"message,omitempty"`
	Errors  []interface{} `json:"errors,omitempty"`
}

type StatusCodeDescription

type StatusCodeDescription struct {
	Type    string
	Message string
}

Jump to

Keyboard shortcuts

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