From ba9357e166a318364e3b28c3adff8618c7d8c591 Mon Sep 17 00:00:00 2001 From: bryanqiu Date: Fri, 24 Nov 2023 11:41:57 +0800 Subject: [PATCH] add GET --- api.go | 6 ++++++ routes.go | 1 + 2 files changed, 7 insertions(+) diff --git a/api.go b/api.go index 9a2f41e..ee27f2e 100644 --- a/api.go +++ b/api.go @@ -54,6 +54,12 @@ func (e *Engine) POST(uri string, handler Handler) { 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 func handlerWrapper(handler Handler) gin.HandlerFunc { handlerFunc := handler.HandlerFunc() diff --git a/routes.go b/routes.go index fe48b6d..eddcd71 100644 --- a/routes.go +++ b/routes.go @@ -47,6 +47,7 @@ type Handler interface { type HandlerFunc func(*Context) error type IRoutes interface { + GET(uri string, handler Handler) POST(uri string, handler Handler) }