change api routerGroup to api package

This commit is contained in:
Jay 2020-08-17 11:06:17 +08:00
parent f6ec10b1f4
commit 63e28b6020
2 changed files with 17 additions and 2 deletions

15
router/routes/api/api.go Normal file
View File

@ -0,0 +1,15 @@
package api
import (
"go-api/pkg/context"
"go-api/router/middleware"
"github.com/gin-gonic/gin"
)
var patch = context.PatchContext
// SetAPIRoute
func SetAPIRoute(r *gin.RouterGroup) {
r.Use(patch(middleware.ServerPanicCatch()))
}

View File

@ -4,6 +4,7 @@ import (
"go-api/pkg/context"
"go-api/router/controller"
"go-api/router/middleware"
"go-api/router/routes/api"
"os"
"github.com/gin-gonic/gin"
@ -37,6 +38,5 @@ func SetRoute(e *gin.Engine) {
e.GET("/api-docs.json", middleware.SwaggerSpecServe())
}
api := e.Group("/api", patch(middleware.ServerPanicCatch()))
_ = api
api.SetAPIRoute(e.Group("/api"))
}