feat 改名
This commit is contained in:
37
Server/gateway/net/http_gateway/router.go
Normal file
37
Server/gateway/net/http_gateway/router.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package http_gateway
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"gateway/handler/http_handler"
|
||||
"gateway/handler/http_handler/helper/render"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func InitRouter() *gin.Engine {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
r := gin.New()
|
||||
r.Use(
|
||||
gin.Recovery(),
|
||||
ginLogger(log.GetLogger().Named("GIN")),
|
||||
cors.New(corsConfig()),
|
||||
)
|
||||
|
||||
r.HandleMethodNotAllowed = true
|
||||
r.NoMethod(func(c *gin.Context) {
|
||||
render.JsonByStatus(c, http.StatusMethodNotAllowed, render.Failed, "Method Not Allowed")
|
||||
})
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
render.JsonByStatus(c, http.StatusNotFound, render.Failed, "Endpoint Not Found")
|
||||
})
|
||||
initBaseRouter(r)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func initBaseRouter(router *gin.Engine) {
|
||||
g := router.Group("/b")
|
||||
g.POST("/snowflake", http_handler.GenSnowflake) // 生成雪花
|
||||
}
|
||||
Reference in New Issue
Block a user