wip: add api auth and /resume endpoint

This commit is contained in:
cătălin 2023-12-04 22:13:37 +01:00
commit aaec8ec08d
Signed by: catalin
GPG key ID: 0178DF42F43E5FD2
23 changed files with 1244 additions and 271 deletions

View file

@ -0,0 +1,43 @@
package http
import (
"git.roboces.dev/catalin/cvvvvv/internal/config"
v1 "git.roboces.dev/catalin/cvvvvv/internal/delivery/http/v1"
"git.roboces.dev/catalin/cvvvvv/internal/service"
"git.roboces.dev/catalin/cvvvvv/pkg/limiter"
"github.com/gin-gonic/gin"
)
type Handler struct {
services *service.Services
}
func NewHandler(services *service.Services) *Handler {
return &Handler{
services: services,
}
}
func (h *Handler) Init(cfg *config.Config) *gin.Engine {
// Init gin handler
router := gin.Default()
router.Use(
gin.Recovery(),
gin.Logger(),
limiter.Limit(cfg.Limiter.RPS, cfg.Limiter.Burst, cfg.Limiter.TTL),
corsMiddleware,
)
h.initAPI(router)
return router
}
func (h *Handler) initAPI(router *gin.Engine) {
handlerV1 := v1.NewHandler(h.services)
api := router.Group("/api")
{
handlerV1.Init(api)
}
}