This commit is contained in:
bryanqiu 2023-11-24 11:41:57 +08:00
parent 9df516247c
commit ba9357e166
2 changed files with 7 additions and 0 deletions

6
api.go
View File

@ -54,6 +54,12 @@ func (e *Engine) POST(uri string, handler Handler) {
e.Engine.POST(uri, h) e.Engine.POST(uri, h)
} }
func (e *Engine) GET(uri string, handler Handler) {
h := handlerWrapper(handler)
log.Infof("api handler [%v] registor success", handler)
e.Engine.GET(uri, h)
}
// handlerWrapper // handlerWrapper
func handlerWrapper(handler Handler) gin.HandlerFunc { func handlerWrapper(handler Handler) gin.HandlerFunc {
handlerFunc := handler.HandlerFunc() handlerFunc := handler.HandlerFunc()

View File

@ -47,6 +47,7 @@ type Handler interface {
type HandlerFunc func(*Context) error type HandlerFunc func(*Context) error
type IRoutes interface { type IRoutes interface {
GET(uri string, handler Handler)
POST(uri string, handler Handler) POST(uri string, handler Handler)
} }