package router import ( "api/config" "api/router/middleware" "github.com/gin-gonic/gin" "net/http" ) func ServerRouter() http.Handler { gin.SetMode(config.Cfg.Server.AppMode) r := gin.New() r.SetTrustedProxies([]string{"*"}) r.Use(middleware.Cors()) // 跨域中间件 // 无需鉴权的接口 base := r.Group("/api") { base.GET("/getHeaders", networkApi.GetHeaders) base.POST("/getIpInfo", ipApi.GetIpInfo) base.POST("/getIpInfoList", ipApi.GetIpInfoList) } return r }