ginx

package
v0.0.0-...-3363d21 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ReqBodyKey = prefix + "/req-body"
	ResBodyKey = prefix + "/res-body"
)

Variables

This section is empty.

Functions

func Bind

func Bind(c *gin.Context, obj interface{}) error

Bind checks the Method and Content-Type to select a binding engine automatically

func GetBodyData

func GetBodyData(c *gin.Context) []byte

GetBodyData Get body data from context

func GetPage

func GetPage(c *gin.Context) (pageNum, pageSize int)

GetPage 获取每页数量

func GetToken

func GetToken(c *gin.Context) string

GetToken Get jwt token from header (Authorization: Bearer xxx)

func ParseForm

func ParseForm(c *gin.Context, obj interface{}) error

ParseForm Parse body form data to struct

func ParseJSON

func ParseJSON(c *gin.Context, obj interface{}) error

ParseJSON Parse body json data to struct

func ParseParamID

func ParseParamID(c *gin.Context, key string) uint64

ParseParamID Param returns the value of the URL param

func ParseQuery

func ParseQuery(c *gin.Context, obj interface{}) error

ParseQuery Parse query parameter to struct

func ResData

func ResData(c *gin.Context, data interface{})

ResData 数据返回

func ResError

func ResError(c *gin.Context, err error, status ...int)

Response error object and parse error status code

func ResJSON

func ResJSON(c *gin.Context, httpCode int, resp interface{})

ResJSON 返回JSON数据

func ResOk

func ResOk(c *gin.Context)

ResOk 返回操作成功

Types

type ResponseData

type ResponseData struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

ResponseData 数据返回结构体

type ResponseFail

type ResponseFail struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

ResponseFail 返回成功结构体

Jump to

Keyboard shortcuts

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