feat:lab4-catchup

This commit is contained in:
Оля Мороз
2026-11-16 11:46:03 +03:00
parent 276dbdad8a
commit 0a361367c7
29 changed files with 2851 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package api
import "net/http"
func NewRouter(h *Handler, instanceID string) http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("GET /health/live", h.Live)
mux.HandleFunc("GET /health/ready", h.Ready)
mux.HandleFunc("POST /api/v1/users", h.CreateUser)
mux.HandleFunc("GET /api/v1/users/me", h.CurrentUser)
mux.HandleFunc("POST /api/v1/auth/sessions", h.CreateSession)
mux.HandleFunc("DELETE /api/v1/auth/sessions/current", h.RevokeSession)
mux.HandleFunc("POST /api/v1/chats", h.CreateChat)
mux.HandleFunc("GET /api/v1/chats", h.ListChats)
mux.HandleFunc("GET /api/v1/chats/{chat_id}", h.GetChat)
mux.HandleFunc("POST /api/v1/chats/{chat_id}/messages", h.CreateMessage)
mux.HandleFunc("GET /api/v1/chats/{chat_id}/messages", h.ListMessages)
mux.HandleFunc("POST /api/v1/chats/{chat_id}/attachments", h.UploadAttachment)
mux.HandleFunc("GET /api/v1/attachments/{attachment_id}", h.GetAttachment)
mux.HandleFunc("GET /api/v1/attachments/{attachment_id}/content", h.DownloadAttachment)
// Порядок: instanceID снаружи, requestID внутри.
return withInstanceID(instanceID)(withRequestID(mux))
}