modified: main_dc/yalarba/api_es/cmd/main.go
modified: main_dc/yalarba/api_es/internal/handler/all_handlers.go modified: main_dc/yalarba/api_es/internal/handler/user_handler.go new file: main_dc/yalarba/api_es/internal/router/router.go add rounter, logger router
This commit is contained in:
@@ -1 +1,33 @@
|
||||
package handler
|
||||
package handler
|
||||
|
||||
import (
|
||||
"api_es/internal/config"
|
||||
"api_es/internal/repository"
|
||||
"api_es/internal/service"
|
||||
"api_es/internal/utils"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type AllHandler struct {
|
||||
userHandler *UserHandler
|
||||
}
|
||||
|
||||
func NewAllHandler(db *gorm.DB, cfg *config.Config) *AllHandler {
|
||||
|
||||
userRepo := repository.NewUserRepository(db)
|
||||
|
||||
userService := service.NewUserService(userRepo, utils.NewJWTUtil(cfg.JWTSecret))
|
||||
|
||||
userHandler := NewUserHandler(userService)
|
||||
|
||||
return &AllHandler{
|
||||
userHandler: userHandler,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (h *AllHandler) UserHandler() *UserHandler {
|
||||
return h.userHandler
|
||||
}
|
||||
@@ -231,8 +231,7 @@ func (h *UserHandler) ListUsers(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(users)
|
||||
}
|
||||
|
||||
func (h *UserHandler) Routes() chi.Router {
|
||||
r := chi.NewRouter()
|
||||
func (h *UserHandler) Routes(r chi.Router) chi.Router {
|
||||
|
||||
r.Route("/auth", func(r chi.Router) {
|
||||
r.Post("/register", h.Register)
|
||||
|
||||
Reference in New Issue
Block a user