You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
967 B

package manage
import (
"github.com/gin-gonic/gin"
"net/http"
"recook/internal/api/manage/file"
"recook/internal/back"
"recook/internal/gateway/manage"
"recook/internal/v2/router"
)
func Service() http.Handler {
e := gin.Default()
v12 := e.Group("/api/v1")
{
v12.POST("/photo/upload", file.UploadPhoto) // 图片上传
}
e.Use(manage.CORS())
e.NoRoute(func(c *gin.Context) {
back.Fail(c, "请求不存在")
})
e.NoMethod(func(c *gin.Context) {
back.Fail(c, "方法不支持")
})
v1 := e.Group("/api/v1")
{
// 裁剪 不裁剪的走ngx 也可以配置nginx裁剪组建
v1.GET("/static/photo/resize/*path", file.ResizePhotos)
manage.SetupRouter(v1)
fileRouter := v1.Group("files")
{
fileRouter.POST("/photo/upload", file.UploadPhoto) // 图片上传
}
}
v2 := e.Group("/api/v2")
{
v2.GET("/health", func(ctx *gin.Context) {
ctx.JSON(200, gin.H{"status": "ok3"})
return
})
router.Router(v2)
}
return e
}