引入文档解析

This commit is contained in:
2025-02-14 22:30:56 +08:00
parent 2f7d1438b2
commit e1f597ae50
7 changed files with 79 additions and 72 deletions

View File

@ -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: