init
This commit is contained in:
31
router/router.go
Executable file
31
router/router.go
Executable file
@@ -0,0 +1,31 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
v1 "video/api/v1"
|
||||
"video/utils/code"
|
||||
"video/utils/exception"
|
||||
)
|
||||
|
||||
func InitRouter() *gin.Engine {
|
||||
gin.SetMode("release")
|
||||
r := gin.Default()
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
c.JSON(http.StatusForbidden, exception.E{Code: code.NOT_FOUND_ROUTE, Msg: "Not Found Route", Err: nil})
|
||||
})
|
||||
r.NoMethod(func(c *gin.Context) {
|
||||
c.JSON(http.StatusForbidden, exception.E{Code: code.NOT_FOUND_METH, Msg: "Not Found Method"})
|
||||
})
|
||||
|
||||
api := r.Group("api")
|
||||
{
|
||||
baseV1 := new(v1.Base)
|
||||
apiV1 := api.Group("v1")
|
||||
{
|
||||
apiV1.POST("base/CallUserNp", baseV1.CallUserNp)
|
||||
apiV1.POST("base/CallUserPb", baseV1.CallUserPb)
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user