32 lines
693 B
Go
Executable File
32 lines
693 B
Go
Executable File
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
|
|
}
|