1 Star 0 Fork 0

Souki/go-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
support_gin.go 706 Bytes
一键复制 编辑 原始数据 按行查看 历史
Souki 提交于 2022-12-03 10:54 +08:00 . remove log
package httpserver
import (
"github.com/gin-gonic/gin"
)
//RouteFromGin 从gin进行路由配置
func (s *HttpServer) RouteFromGin(r *gin.Engine) *HttpServer {
for _, v := range r.Routes() {
s.addRouteHandler(v.Method, v.Path, r, nil)
}
return s
}
//RouteToGin 路由配置copy至gin
func (s *HttpServer) RouteToGin(engine *gin.Engine) *HttpServer {
routers := map[string]*Router{}
for _, x := range s.routers {
routers[x.hash()] = x
}
dict := map[string]bool{}
for _, x := range engine.Routes() {
dict[x.Method+"_"+x.Path] = true
}
for _, r := range routers {
if dict[r.Method+"_"+r.Path] {
continue
}
engine.Handle(r.Method, r.Path, r.handlerGin(s.config))
}
return s
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/scottq/go-framework.git
git@gitee.com:scottq/go-framework.git
scottq
go-framework
go-framework
v1.1.43-beta

搜索帮助