Перенести WithUser в httpx

This commit is contained in:
2026-10-06 14:49:19 +03:00
parent f42bf97b3a
commit 6720108793
6 changed files with 60 additions and 48 deletions
+6 -7
View File
@@ -6,7 +6,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"messenger/internal/auth"
"messenger/internal/platform/apperr"
"messenger/internal/platform/httpx"
"messenger/internal/platform/ident"
@@ -21,13 +20,13 @@ func NewHandler(chats *Service) *Handler {
return &Handler{chats: chats}
}
// Register mounts the chat endpoints on a router guarded by RequireUser.
// Register mounts the chat endpoints on a router guarded by the authentication middleware.
func (h *Handler) Register(protected gin.IRouter) {
protected.POST("/chats", auth.WithUser(h.create))
protected.GET("/chats", auth.WithUser(h.list))
protected.GET("/chats/:chat_id", auth.WithUser(h.get))
protected.POST("/chats/:chat_id/messages", auth.WithUser(h.send))
protected.GET("/chats/:chat_id/messages", auth.WithUser(h.history))
protected.POST("/chats", httpx.WithUser(h.create))
protected.GET("/chats", httpx.WithUser(h.list))
protected.GET("/chats/:chat_id", httpx.WithUser(h.get))
protected.POST("/chats/:chat_id/messages", httpx.WithUser(h.send))
protected.GET("/chats/:chat_id/messages", httpx.WithUser(h.history))
}
type createChatRequest struct {