apis

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fail

func Fail(c *gin.Context, code int, args ...interface{})

Fail response fail with code, err, field

func Ok

func Ok(c *gin.Context, args ...interface{})

Ok ...

func Out

func Out(c *gin.Context, code int, args ...interface{})

Out ...

func Register

func Register(name string, sf Strapper)

Register ...

func Routers

func Routers(r gin.IRouter, names ...string)

Routers ...

Types

type Error

type Error struct {
	Code    int    `json:"code" description:"错误代码"`
	Message string `json:"message,required" description:"错误信息"`
	Field   string `json:"field,omitempty" description:"错误字段,可选,多用于表单校验"`
}

Error ...

func GetError

func GetError(r *http.Request, code int, err interface{}, args ...interface{}) Error

type ICodeErrorReq added in v0.12.2

type ICodeErrorReq interface {
	Code() int
	ErrorReq(r *http.Request) string
}

ICodeErrorReq ...

type IError

type IError interface {
	GetCode() int
	GetMessage() string
	GetField() string
}

IError ...

type IFieldErrorReq added in v0.12.2

type IFieldErrorReq interface {
	ErrorReq(r *http.Request) string
	Field() string
}

IFieldErrorReq ...

type RespDone added in v0.12.2

type RespDone struct {
	Ok    bool        `json:"ok,required" description:"操作成功"` // OK
	Data  interface{} `json:"data,omitempty"`                 // main data
	Extra interface{} `json:"extra,omitempty"`                // extra data
}

RespDone 操作成功返回的结构

type RespFail added in v0.12.2

type RespFail struct {
	Ok    bool  `json:"ok" description:"操作失败"`
	Error Error `json:"error" description:"错误集"`
}

RespFail 出现错误,返回相关的错误码和消息文本

type StrapFunc

type StrapFunc func(r gin.IRouter)

StrapFunc ...

func (StrapFunc) Strap

func (f StrapFunc) Strap(r gin.IRouter)

Strap ...

type Strapper

type Strapper interface {
	Strap(r gin.IRouter)
}

Strapper ...

Jump to

Keyboard shortcuts

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