annotation/internal/router/router.go

34 lines
808 B
Go

package router
import (
"git.hpds.cc/Component/logging"
ginzap "github.com/gin-contrib/zap"
"github.com/gin-gonic/gin"
"hpds_annotation/config"
"hpds_annotation/internal/handler"
"hpds_annotation/internal/middleware"
e "hpds_annotation/pkg/err"
)
func InitRouter(cfg *config.WebConfig, logger *logging.Logger) *gin.Engine {
hs := handler.NewHandlerService(cfg, logger)
gin.SetMode(gin.ReleaseMode)
root := gin.New()
root.Use(ginzap.Ginzap(logger.Logger, "2006-01-02 15:04:05.000", true))
root.Use(middleware.Cors())
r := root.Group("/api")
{
dir := r.Group("/directory")
{
dir.POST("/list", e.ErrorWrapper(hs.GetList))
dir.POST("/info", e.ErrorWrapper(hs.GetInfo))
}
label := r.Group("/label")
{
label.POST("/submit", e.ErrorWrapper(hs.LabelSubmit))
}
}
return root
}