25 lines
1.1 KiB
Go
25 lines
1.1 KiB
Go
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))
|
|
}
|