serializers

package
v0.0.0-...-07ef03e Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Success            = 0
	WrongKey           = -1
	Pending            = -2
	RequireAttention   = -3
	NotFound           = -4
	UnknownError       = -5
	HasDoneAlready     = -6
	NotEnoughResources = -7
	Unauthorized       = -8
	InvalidInput       = -10
	Timeout            = -11
)

定义错误码, 保证前端可以快速接入

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	Code      int         `json:"code"`
	Message   string      `json:"message,omitempty"`
	Data      interface{} `json:"data,omitempty"`
	Error     string      `json:"error,omitempty"`
	Timestamp int64       `json:"timestamp,omitempty"`
}

Response 基础序列化器

func DatabaseErrorResponse

func DatabaseErrorResponse(message string, err error) Response

数据库错误

func ErrorResponse

func ErrorResponse(errorCode int, message string, err error) Response

标准错误

func ParamaterErrorResponse

func ParamaterErrorResponse(message string, err error) Response

参数错误

func ParamaterErrorResponseBuilder

func ParamaterErrorResponseBuilder(err error) Response

func (Response) Result

func (response Response) Result() *Response

type TrackedErrorResponse

type TrackedErrorResponse struct {
	Response
	TrackID string `json:"track_id"`
}

TrackedErrorResponse 有追踪信息的错误响应

func (TrackedErrorResponse) Result

func (response TrackedErrorResponse) Result() *TrackedErrorResponse

Jump to

Keyboard shortcuts

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