annotation/internal/router/router.go

38 lines
910 B
Go
Raw Permalink Normal View History

2023-05-12 16:53:21 +08:00
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))
}
capture := r.Group("/capture")
{
capture.POST("/submit", e.ErrorWrapper(hs.CaptureSubmit))
}
2023-05-12 16:53:21 +08:00
}
return root
}