Files
auth-service/internal/handler/handler.go

40 lines
685 B
Go

package handler
import (
"authorization/internal/service"
"github.com/gin-gonic/gin"
)
type Handler struct {
services *service.Service
}
func NewHandler(services *service.Service) *Handler {
return &Handler{
services: services,
}
}
func (h *Handler) InitRoutes() *gin.Engine {
router := gin.New()
serviceRouter := router.Group("/auth-service")
{
auth := serviceRouter.Group("/auth")
{
auth.POST("/sign-up", h.signUp)
auth.POST("/sign-in", h.signIn)
auth.POST("/refresh", h.refresh)
}
api := router.Group("/api")
{
users := api.Group("/users", h.checkAdminIdentity)
{
users.POST("/:username", h.changeUserRole)
}
}
}
return router
}