Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InfoLoggerMiddleware ¶
func InfoLoggerMiddleware(log *tlog.Logger) gin.HandlerFunc
请求信息日志中间件
会记录 请求时间、请求的ip、请求的url、请求的方法、状态码、响应时间
func Register ¶
注册一个http服务下的一个路由 如果重复传入会触发panic 示例: type Apier struct { } func (a Apier) SetApi(router *gin.Engine) { create(router) } func init() { router.Register("service","code","v1", &Apier{}) } func create(router *gin.Engine) { router.GET("/create", func(c *gin.Context) { c.String(http.StatusOK, "user") }) }
实际url为:code/v1/create
Types ¶
type Router ¶
type Router interface { // 设置路由 SetRouter(router *gin.RouterGroup) []gin.IRoutes // 设置中间件 SetMiddleware() []gin.HandlerFunc }
路由接口
Click to show internal directories.
Click to hide internal directories.