This commit is contained in:
coward
2024-07-05 14:41:35 +08:00
commit 1f7f57ec9f
70 changed files with 4923 additions and 0 deletions

35
http/router/root.go Normal file
View File

@@ -0,0 +1,35 @@
package router
import (
"github.com/gin-gonic/gin"
)
type Option func(engine *gin.RouterGroup)
var options []Option
func includeRouters(opts ...Option) {
options = append(options, opts...)
}
func InitRouter() *gin.Engine {
r := gin.New()
// 开启IP 追踪
r.ForwardedByClientIP = true
// 将请求打印至控制台
r.Use(gin.Logger())
for _, opt := range options {
opt(r.Group("api"))
}
return r
}
func Rooters() {
includeRouters(
LoginApi,
UserApi,
ClientApi,
)
}