new file: main_dc/yalarba/api_yal/internal/handlers/allHandlers.go
modified: main_dc/yalarba/api_yal/internal/router/router.go add allhandlers.go file
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import ()
|
||||||
|
|
||||||
|
type AllHandler struct {
|
||||||
|
authHandler *AuthHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAllHandler() *AllHandler {
|
||||||
|
return &AllHandler{
|
||||||
|
authHandler: NewAuthHandler(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *AllHandler) AuthHandler() *AuthHandler {
|
||||||
|
return h.authHandler
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ package router
|
|||||||
import (
|
import (
|
||||||
"api_yal/internal/config"
|
"api_yal/internal/config"
|
||||||
"api_yal/internal/logger"
|
"api_yal/internal/logger"
|
||||||
|
"api_yal/internal/handlers"
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@@ -14,6 +16,7 @@ func SetupRouter(db *gorm.DB, config *config.Config) http.Handler {
|
|||||||
zapLogger := logger.Get()
|
zapLogger := logger.Get()
|
||||||
zapLogger.Info("Start setup routers")
|
zapLogger.Info("Start setup routers")
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
|
h := handlers.NewAllHandler()
|
||||||
|
|
||||||
// Health check
|
// Health check
|
||||||
r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
|
r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -22,6 +25,10 @@ func SetupRouter(db *gorm.DB, config *config.Config) http.Handler {
|
|||||||
json.NewEncoder(w).Encode(map[string]string{"status": "healthy"})
|
json.NewEncoder(w).Encode(map[string]string{"status": "healthy"})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
r.Route("/auth", func(r chi.Router) {
|
||||||
|
r.Post("/register", h.AuthHandler().HandleAuth)
|
||||||
|
})
|
||||||
|
|
||||||
zapLogger.Info("End setup routers")
|
zapLogger.Info("End setup routers")
|
||||||
|
|
||||||
// Логируем все зарегистрированные маршруты
|
// Логируем все зарегистрированные маршруты
|
||||||
|
|||||||
Reference in New Issue
Block a user