package app

import (
	"file_upload/app/controller"
	middleware "file_upload/app/middlewares"
	"file_upload/global"
	"github.com/gin-gonic/gin"
	//swaggerFiles "github.com/swaggo/files"
	//ginSwagger "github.com/swaggo/gin-swagger"
)

func InitRouter() error {
	engine := gin.New()
	//记录日志
	engine.Use(middleware.Cors())
	//engine.GET("/swagger/*any", ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, global.SwaggerSetting.Enable))
	gin.SetMode(global.ServerSetting.Mode)
	group := engine.Group("/api")
	group.Use(middleware.Cors())
	group.DELETE("/template", controller.DeleteTemplate)
	group.POST("/savefile", controller.SaveFile)
	group.POST("/template", controller.TemplateItem)
	group.GET("/template", controller.GetTemplate)
	group.GET("/search", controller.SearchTemplate)
	return engine.Run(global.ServerSetting.Port)
}
