api

package
v0.0.0-...-9132bf9 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SUCCESS 成功
	SUCCESS = "ok" // 成功
	// ReqDataValError 请求数据校验失败
	ReqDataValError = "参数解析失败" // 请求数据校验失败
	// InternalServerError 服务器内部错误
	InternalServerError = "服务器内部错误"
	// Unauthorized session认证失败
	Unauthorized = "认证失败" // session认证失败
	// NotFound 未找到相关资源
	NotFound = "未找到相关资源" // 未找到相关资源
	// Expired 页面过期
	Expired = "页面过期" // 页面过期
	// Refuse 正在发布拒绝执行
	Refuse = "请求被拒绝,建议刷新页面" // 正在发布拒绝执行

)

Variables

This section is empty.

Functions

func Send

func Send(ctx *gin.Context, resData interface{}, err *errors.Error)

Send 返回结果

func SendInternalServerError

func SendInternalServerError(ctx *gin.Context, err *errors.Error)

SendInternalServerError 服务器内部错误

func SendNotFound

func SendNotFound(ctx *gin.Context, err *errors.Error)

SendNotFound 服务器内部错误

func SendOK

func SendOK(ctx *gin.Context)

SendOK 成功

func SendParamParseError

func SendParamParseError(ctx *gin.Context, err *errors.Error)

SendParamParseError 返回参数解析失败错误

func SendRefuse

func SendRefuse(ctx *gin.Context, err *errors.Error)

SendRefuse 拒绝请求

func SendUnauthorized

func SendUnauthorized(ctx *gin.Context, err *errors.Error)

SendUnauthorized 身份认证失败

Types

type Response

type Response struct {
	Success bool        `json:"success"`        // 请求是否成功
	Data    interface{} `json:"data"`           // 数据
	Code    int         `json:"code,omitempty"` // 错误码
	Msg     string      `json:"msg"`            // 错误提示
}

Response 返回格式

func DefaultRes

func DefaultRes() *Response

DefaultRes 默认

Jump to

Keyboard shortcuts

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