sgchttp

package
v0.0.0-...-f278672 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CrossOrigin

func CrossOrigin(c *gin.Context)

CrossOrigin is a middleware function that appends headers for options requests and aborts then exits the middleware chain and ends the request. 解决跨域问题

func Error

func Error(c *gin.Context, code int, err error, msg string)

Error 失败数据处理

func Error204

func Error204(c *gin.Context, err error, msg string)

Error204 简化版204错误处理

func Error400

func Error400(c *gin.Context, err error, msg string)

Error400 简化版400错误处理

func Json

func Json(c *gin.Context, t interface{}) (obj interface{}, err error)

func Ok

func Ok(c *gin.Context, data interface{}, msg string)

Ok 通常成功数据处理

func ReadObj

func ReadObj(c *gin.Context, t interface{}) (obj interface{}, err error)

ReadObj 获取请求中的对象

Types

type PageVto

type PageVto struct {
	List      interface{} `json:"list"`
	Count     int         `json:"count"`
	PageIndex int         `json:"pageIndex"`
	PageSize  int         `json:"pageSize"`
}

PageVto 返回分页格式

type ResponseVto

type ResponseVto struct {
	// 代码
	Code int `json:"code" example:"200"`
	// 数据集
	Data interface{} `json:"data"`
	// 消息
	Msg       string `json:"msg"`
	RequestID string `json:"requestId"`
}

ResponseVto 返回消息的格式

func (*ResponseVto) ReturnError

func (res *ResponseVto) ReturnError(code int) *ResponseVto

ReturnError 返回错误

func (*ResponseVto) ReturnOk

func (res *ResponseVto) ReturnOk() *ResponseVto

ReturnOk 返回ok

Jump to

Keyboard shortcuts

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