package routess import ( _ "blog/docs" "blog/global" "blog/internal/middleware" "blog/internal/routess/api" v1 "blog/internal/routess/api/v1" "github.com/gin-gonic/gin" swaggerFiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" "net/http" ) func NewRouter() *gin.Engine { r := gin.New() r.Use(gin.Logger()) r.Use(gin.Recovery()) r.Use(middleware.Translations()) article := v1.NewArticle() tag := v1.NewTag() upload := api.NewUpload() r.POST("/upload/file", upload.UploadFile) r.StaticFS("/static", http.Dir(global.AppSetting.UploadSavePath)) //r.GET("/static/*any",api.ReadFile) r.GET("/doc/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) r.POST("/auth", api.GetAuth) apiv1 := r.Group("/api/v1") apiv1.Use(middleware.JWT()) { apiv1.POST("/tags", tag.Create) apiv1.DELETE("/tags/:id", tag.Delete) apiv1.PUT("/tags/:id", tag.Update) apiv1.PATCH("/tags/:id/state", tag.Update) apiv1.GET("/tags", tag.List) apiv1.POST("/articles", article.Create) apiv1.DELETE("/articles/:id", article.Delete) apiv1.PUT("/articles/:id", article.Update) apiv1.PATCH("/articles/:id/state", article.Update) apiv1.GET("/articles/:id", article.Get) apiv1.GET("/articles", article.List) } return r }