chore: 小调整
This commit is contained in:
parent
ccd6289c9c
commit
4485790236
@ -49,7 +49,7 @@ func Default() *Engine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type HandleFunc func(c *Context)
|
type HandlerFunc func(c *Context)
|
||||||
|
|
||||||
func handleFunc(hd func(c *Context)) func(ctx *gin.Context) {
|
func handleFunc(hd func(c *Context)) func(ctx *gin.Context) {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
@ -60,7 +60,7 @@ func handleFunc(hd func(c *Context)) func(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重写路由组注册
|
// 重写路由组注册
|
||||||
func (app *Engine) Group(relativePath string, handlers ...HandleFunc) *Router {
|
func (app *Engine) Group(relativePath string, handlers ...HandlerFunc) *Router {
|
||||||
hds := make([]gin.HandlerFunc, 0)
|
hds := make([]gin.HandlerFunc, 0)
|
||||||
for _, hd := range handlers {
|
for _, hd := range handlers {
|
||||||
hds = append(hds, handleFunc(hd))
|
hds = append(hds, handleFunc(hd))
|
||||||
@ -71,7 +71,7 @@ func (app *Engine) Group(relativePath string, handlers ...HandleFunc) *Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重写根GET请求
|
// 重写根GET请求
|
||||||
func (app *Engine) GET(relativePath string, handlers ...HandleFunc) gin.IRoutes {
|
func (app *Engine) GET(relativePath string, handlers ...HandlerFunc) gin.IRoutes {
|
||||||
hds := make([]gin.HandlerFunc, 0)
|
hds := make([]gin.HandlerFunc, 0)
|
||||||
for _, hd := range handlers {
|
for _, hd := range handlers {
|
||||||
hds = append(hds, handleFunc(hd))
|
hds = append(hds, handleFunc(hd))
|
||||||
@ -80,7 +80,7 @@ func (app *Engine) GET(relativePath string, handlers ...HandleFunc) gin.IRoutes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重写根POST请求
|
// 重写根POST请求
|
||||||
func (app *Engine) POST(relativePath string, handlers ...HandleFunc) gin.IRoutes {
|
func (app *Engine) POST(relativePath string, handlers ...HandlerFunc) gin.IRoutes {
|
||||||
hds := make([]gin.HandlerFunc, 0)
|
hds := make([]gin.HandlerFunc, 0)
|
||||||
for _, hd := range handlers {
|
for _, hd := range handlers {
|
||||||
hds = append(hds, handleFunc(hd))
|
hds = append(hds, handleFunc(hd))
|
||||||
@ -89,7 +89,7 @@ func (app *Engine) POST(relativePath string, handlers ...HandleFunc) gin.IRoutes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重写子GET请求
|
// 重写子GET请求
|
||||||
func (r *Router) GET(relativePath string, handlers ...HandleFunc) gin.IRoutes {
|
func (r *Router) GET(relativePath string, handlers ...HandlerFunc) gin.IRoutes {
|
||||||
hds := make([]gin.HandlerFunc, 0)
|
hds := make([]gin.HandlerFunc, 0)
|
||||||
for _, hd := range handlers {
|
for _, hd := range handlers {
|
||||||
hds = append(hds, handleFunc(hd))
|
hds = append(hds, handleFunc(hd))
|
||||||
@ -98,7 +98,7 @@ func (r *Router) GET(relativePath string, handlers ...HandleFunc) gin.IRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重写子 POST 请求
|
// 重写子 POST 请求
|
||||||
func (r *Router) POST(relativePath string, handlers ...HandleFunc) gin.IRoutes {
|
func (r *Router) POST(relativePath string, handlers ...HandlerFunc) gin.IRoutes {
|
||||||
hds := make([]gin.HandlerFunc, 0)
|
hds := make([]gin.HandlerFunc, 0)
|
||||||
for _, hd := range handlers {
|
for _, hd := range handlers {
|
||||||
hds = append(hds, handleFunc(hd))
|
hds = append(hds, handleFunc(hd))
|
||||||
@ -107,7 +107,7 @@ func (r *Router) POST(relativePath string, handlers ...HandleFunc) gin.IRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重写中间件注册
|
// 重写中间件注册
|
||||||
func (r *Router) Use(mws ...HandleFunc) gin.IRoutes {
|
func (r *Router) Use(mws ...HandlerFunc) gin.IRoutes {
|
||||||
hds := make([]gin.HandlerFunc, 0)
|
hds := make([]gin.HandlerFunc, 0)
|
||||||
for _, mw := range mws {
|
for _, mw := range mws {
|
||||||
hds = append(hds, handleFunc(mw))
|
hds = append(hds, handleFunc(mw))
|
||||||
|
@ -9,7 +9,6 @@ package gweb
|
|||||||
|
|
||||||
import "github.com/gin-gonic/gin"
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
// type Engine = gin.Engine
|
|
||||||
type H = gin.H
|
type H = gin.H
|
||||||
type HandlersChain = gin.HandlersChain
|
type HandlersChain = gin.HandlersChain
|
||||||
type RouteInfo = gin.RouteInfo
|
type RouteInfo = gin.RouteInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user