完善 RequestHandler 逻辑

This commit is contained in:
2025-02-07 16:10:33 +08:00
parent 196c437cc5
commit 77ea723e86
4 changed files with 99 additions and 15 deletions

View File

@ -8,6 +8,7 @@
package router
import (
"errors"
"github.com/gin-gonic/gin"
"net/http"
"strings"
@ -28,8 +29,21 @@ func Group(router *gin.Engine, routerPrefix string, middlewareList []gin.Handler
method := strings.ToUpper(itemUriCfg.Method)
switch method {
case http.MethodGet:
g.HEAD(itemUriCfg.Path)
g.GET(itemUriCfg.Path, RequestHandler(itemUriCfg))
case http.MethodHead:
g.HEAD(itemUriCfg.Path, RequestHandler(itemUriCfg))
case http.MethodPost:
g.POST(itemUriCfg.Path, RequestHandler(itemUriCfg))
case http.MethodPut:
g.PUT(itemUriCfg.Path, RequestHandler(itemUriCfg))
case http.MethodPatch:
g.PATCH(itemUriCfg.Path, RequestHandler(itemUriCfg))
case http.MethodDelete:
g.DELETE(itemUriCfg.Path, RequestHandler(itemUriCfg))
case http.MethodOptions:
g.OPTIONS(itemUriCfg.Path, RequestHandler(itemUriCfg))
case http.MethodTrace:
return errors.New(`method Trace is not supported`)
}
}
}