Release v0.20: регистрация, авторизация, личный кабинет
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+13
-1
@@ -11,6 +11,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"shop/internal/auth"
|
||||
"shop/internal/check"
|
||||
"shop/internal/config"
|
||||
"shop/internal/database"
|
||||
@@ -49,9 +50,16 @@ func main() {
|
||||
log.Fatalf("templates: %v", err)
|
||||
}
|
||||
|
||||
users := repository.NewUserRepository(pool)
|
||||
sessions := repository.NewSessionRepository(pool)
|
||||
authSvc := auth.NewService(users, sessions, cfg.SessionTTL, cfg.CookieSecure)
|
||||
|
||||
pages := handlers.NewPages(tmpl, authSvc)
|
||||
products := repository.NewProductRepository(pool)
|
||||
home := handlers.NewHomeHandler(products, tmpl)
|
||||
home := handlers.NewHomeHandler(products, pages)
|
||||
health := handlers.NewHealthHandler(pool)
|
||||
authH := handlers.NewAuthHandler(pages, authSvc)
|
||||
account := handlers.NewAccountHandler(pages, authSvc)
|
||||
|
||||
staticSub, err := fs.Sub(web.StaticFS, "static")
|
||||
if err != nil {
|
||||
@@ -63,6 +71,10 @@ func main() {
|
||||
mux.HandleFunc("GET /health", health.Health)
|
||||
mux.HandleFunc("GET /version", health.Version)
|
||||
mux.Handle("GET /", home)
|
||||
mux.HandleFunc("/register", authH.Register)
|
||||
mux.HandleFunc("/login", authH.Login)
|
||||
mux.HandleFunc("POST /logout", authH.Logout)
|
||||
mux.HandleFunc("/account", account.Account)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: cfg.HTTPAddr,
|
||||
|
||||
Reference in New Issue
Block a user