引入文档解析
This commit is contained in:
@ -9,9 +9,10 @@ package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// NewServer server实例
|
||||
@ -24,13 +25,15 @@ func NewServer(port int, option any) *server {
|
||||
panic("port should be greater than 80")
|
||||
}
|
||||
return &server{
|
||||
router: gin.Default(),
|
||||
router: gin.Default(),
|
||||
docInstance: NewDoc(nil, nil), // TODO : 配置相关信息
|
||||
}
|
||||
}
|
||||
|
||||
type server struct {
|
||||
router *gin.Engine
|
||||
port int
|
||||
router *gin.Engine
|
||||
port int
|
||||
docInstance *Doc
|
||||
}
|
||||
|
||||
// Start 启动服务
|
||||
@ -56,6 +59,7 @@ func (s *server) Group(routerPrefix string, middlewareList []gin.HandlerFunc, cL
|
||||
for _, c := range cList {
|
||||
urlTable := cParser.Parse(c)
|
||||
for _, itemUriCfg := range urlTable {
|
||||
s.docInstance.Add(routerPrefix, itemUriCfg.FormDataType, itemUriCfg.ResultDataType)
|
||||
method := strings.ToUpper(itemUriCfg.RequestMethod)
|
||||
switch method {
|
||||
case http.MethodGet:
|
||||
|
Reference in New Issue
Block a user