diff --git a/router/routes/api/api.go b/router/routes/api/api.go new file mode 100644 index 0000000..14874a7 --- /dev/null +++ b/router/routes/api/api.go @@ -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())) +} diff --git a/router/routes/routes.go b/router/routes/routes.go index cbe3a68..5eaf572 100644 --- a/router/routes/routes.go +++ b/router/routes/routes.go @@ -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")) }