forked from mtusi2026/mtusi2026lab4
feat(attachments): add upload, metadata and content endpoints
This commit is contained in:
@@ -16,11 +16,13 @@ func NewRouter(
|
||||
log *slog.Logger,
|
||||
instanceID string,
|
||||
maxInflightRequests int,
|
||||
maxUploadBytes int,
|
||||
db handler.Pinger,
|
||||
authService *service.AuthService,
|
||||
userService *service.UserService,
|
||||
chatService *service.ChatService,
|
||||
messageService *service.MessageService,
|
||||
attachmentService *service.AttachmentService,
|
||||
) http.Handler {
|
||||
router := chi.NewRouter()
|
||||
|
||||
@@ -29,6 +31,7 @@ func NewRouter(
|
||||
userHandler := handler.NewUserHandler(userService)
|
||||
chatHandler := handler.NewChatHandler(chatService)
|
||||
messageHandler := handler.NewMessageHandler(messageService)
|
||||
attachmentHandler := handler.NewAttachmentHandler(attachmentService, maxUploadBytes)
|
||||
|
||||
router.Use(middleware.InstanceID(instanceID))
|
||||
router.Use(middleware.RequestTimeout(5 * time.Second))
|
||||
@@ -55,6 +58,10 @@ func NewRouter(
|
||||
|
||||
r.Post("/api/v1/chats/{chat_id}/messages", messageHandler.Create)
|
||||
r.Get("/api/v1/chats/{chat_id}/messages", messageHandler.List)
|
||||
|
||||
r.Post("/api/v1/chats/{chat_id}/attachments", attachmentHandler.Upload)
|
||||
r.Get("/api/v1/attachments/{attachment_id}", attachmentHandler.Get)
|
||||
r.Get("/api/v1/attachments/{attachment_id}/content", attachmentHandler.GetContent)
|
||||
})
|
||||
|
||||
router.Handle("/swagger/*", http.StripPrefix("/swagger/", http.FileServer(http.Dir("web/swagger"))))
|
||||
|
||||
Reference in New Issue
Block a user