router

package
v0.0.0-...-3377335 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MulanPSL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Failure

func Failure(c *gin.Context, err error)

失败并终止中间件处理流程

func Recovery

func Recovery() gin.HandlerFunc

恢复panic的中间件

func Router

func Router[REQ any, RSP any](handler RouterHandler[REQ, RSP]) gin.HandlerFunc

(自动处理返回值) 路由处理流程

func RouterNoResponse

func RouterNoResponse[REQ any, RSP any](handler RouterHandler[REQ, RSP]) gin.HandlerFunc

(不处理返回值) 路由处理流程

func Success

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

返回成功消息

Types

type NO_OBJ

type NO_OBJ map[string]interface{}

没有REQ或RSP

type Response

type Response struct {
	Status    bool        `json:"status"`    // 是否成功
	Message   string      `json:"message"`   // 错误消息
	Data      interface{} `json:"data"`      // 数据区
	Timestamp int64       `json:"timestamp"` // 时间戳
}

用于Json二次反序列化的返回结果格式

type RouterHandler

type RouterHandler[REQ any, RSP any] func(*gin.Context, REQ) (RSP, error)

通用路由处理函数

Jump to

Keyboard shortcuts

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