api-server/router/server_router.go
2024-09-25 16:35:07 +08:00

26 lines
493 B
Go

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
}