lab4 done

This commit is contained in:
Khakimov Dmitrij
2026-10-28 22:41:10 +03:00
parent a7bedda183
commit dbc700fafe
75 changed files with 5611 additions and 227 deletions
+11 -4
View File
@@ -1,6 +1,7 @@
package chat
import (
"gitflic.ru/akselbant/mtusi2026lab1-fork/internal/attachment"
"log"
"os"
"sync/atomic"
@@ -13,10 +14,11 @@ import (
// Chat is the HTTP handler and depends only on the application boundary.
type Chat struct {
instanceID string
draining atomic.Bool
useCase UseCase
cursor cursorCodec
attachments *attachment.Service
instanceID string
draining atomic.Bool
useCase UseCase
cursor cursorCodec
}
func NewChat(useCase UseCase, cursorKey [32]byte) *Chat {
@@ -81,6 +83,11 @@ func (h *Chat) Router() *echo.Echo {
api.GET("/chats/:chat_id", h.getChat)
api.POST("/chats/:chat_id/messages", h.createMessage)
api.GET("/chats/:chat_id/messages", h.listMessages)
if h.attachments != nil {
api.POST("/chats/:chat_id/attachments", h.uploadAttachment)
api.GET("/attachments/:attachment_id", h.getAttachment)
api.GET("/attachments/:attachment_id/content", h.attachmentContent)
}
return e
}