api

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK = 20000 // RFC 9110, 15.3.1

	StatusBadRequest       = 40000 // RFC 9110, 15.5.1
	StatusParamError       = 40001 // RFC 9110, 15.5.1
	StatusUnauthorized     = 40100 // RFC 9110, 15.5.2
	StatusNotToken         = 40101 // RFC 9110, 15.5.2
	StatusTokenExpired     = 40102 // RFC 9110, 15.5.2
	StatusTokenIpError     = 40103 // RFC 9110, 15.5.2
	StatusForbidden        = 40300 // RFC 9110, 15.5.4
	StatusNotFound         = 40400 // RFC 9110, 15.5.5
	StatusMethodNotAllowed = 40500 // RFC 9110, 15.5.6

	StatusInternalServerError = 50000 // RFC 9110, 15.6.1
	StatusNotImplemented      = 50100 // RFC 9110, 15.6.2
	StatusBadGateway          = 50200 // RFC 9110, 15.6.3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonResult

type JsonResult struct {
	// code
	Code int `json:"code" default:"0"`
	// response information
	Msg string `json:"msg" default:""`
	// data
	Data any `json:"data,omitempty" default:"nil"` // 默认无数据时不显示该字段
	// whether success
	Success bool `json:"success" default:"false"`
}

func NewNo

func NewNo(code int, msg string) *JsonResult

func NewYes

func NewYes(data any) *JsonResult

func (*JsonResult) SetCode

func (j *JsonResult) SetCode(code int) *JsonResult

func (*JsonResult) SetData

func (j *JsonResult) SetData(data any) *JsonResult

func (*JsonResult) SetMsg

func (j *JsonResult) SetMsg(msg string) *JsonResult

func (*JsonResult) SetSuccess

func (j *JsonResult) SetSuccess(success bool) *JsonResult

Jump to

Keyboard shortcuts

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