chore(solution): pull lab2 solution

This commit is contained in:
2026-11-06 02:34:43 +03:00
parent 0ab3a341aa
commit de2f63b926
41 changed files with 2636 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package router
import (
"net/http"
"github.com/go-chi/chi/v5"
"messenger/internal/handler"
)
func New(h *handler.Handler) http.Handler {
r := chi.NewRouter()
r.Use(handler.RequestID, h.AccessLog, h.Recoverer)
r.NotFound(h.NotFound)
r.MethodNotAllowed(h.MethodNotAllowed)
r.Get("/health/live", h.Live)
r.Get("/health/ready", h.Ready)
r.Route("/api/v1", func(r chi.Router) {
r.Post("/users", h.RegisterUser)
r.Post("/auth/sessions", h.CreateSession)
r.Group(func(r chi.Router) {
r.Use(h.Authenticate)
r.Delete("/auth/sessions/current", h.DeleteSession)
r.Get("/users/me", h.CurrentUser)
r.Post("/chats", h.CreateChat)
r.Get("/chats", h.ListChats)
r.Get("/chats/{chat_id}", h.GetChat)
r.Post("/chats/{chat_id}/messages", h.SendMessage)
r.Get("/chats/{chat_id}/messages", h.ListMessages)
})
})
return r
}