gin

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SuccessRespHeader        = BaseRespHeader{Code: http.StatusOK, Msg: "ok"}
	SystemErrorRespHeader    = BaseRespHeader{Code: http.StatusInternalServerError, Msg: "系统异常"}
	ParamErrorRespHeader     = BaseRespHeader{Code: http.StatusBadRequest, Msg: "参数错误"}
	ForbiddenErrorRespHeader = BaseRespHeader{Code: http.StatusForbidden, Msg: "拒绝服务"}
	UnauthorizedRespHeader   = BaseRespHeader{Code: http.StatusUnauthorized, Msg: "未登录"}
)

Functions

func EasyHandler

func EasyHandler(cf CheckFunc, lf LogicFunc, req interface{}) gin.HandlerFunc

解析请求,整合检查请求参数,响应逻辑,并响应

func URLPatterns

func URLPatterns(route RouteAdapter, path string, childRoute DoChildRouteFunc, middles ...gin.HandlerFunc)

URL 调度器

Types

type BaseReqInter

type BaseReqInter interface {
	JSON(ctx *gin.Context) error
}

type BaseRespHeader

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

type BaseRespInter

type BaseRespInter = interface{}

type CheckFunc

type CheckFunc func(ctx *gin.Context, req BaseReqInter) (BaseRespInter, error)

type DoChildRouteFunc

type DoChildRouteFunc func(g *gin.RouterGroup) // 子路由

type LogicFunc

type LogicFunc func(ctx *gin.Context, req BaseReqInter) BaseRespInter

type RouteAdapter

type RouteAdapter interface {
	Use(middleware ...gin.HandlerFunc) gin.IRoutes
	Group(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup
}

用于适配 Engine 和 RouteGroup

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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