feat(httpapi):lab4 register attachment routes in router
This commit is contained in:
@@ -8,11 +8,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Handlers struct {
|
type Handlers struct {
|
||||||
Health *handler.HealthHandler
|
Health *handler.HealthHandler
|
||||||
User *handler.UserHandler
|
User *handler.UserHandler
|
||||||
Chat *handler.ChatHandler
|
Chat *handler.ChatHandler
|
||||||
Message *handler.MessageHandler
|
Message *handler.MessageHandler
|
||||||
Auth *handler.AuthHandler
|
Auth *handler.AuthHandler
|
||||||
|
Attachment *handler.AttachmentHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRouter(h Handlers, auth gin.HandlerFunc) *gin.Engine {
|
func NewRouter(h Handlers, auth gin.HandlerFunc) *gin.Engine {
|
||||||
@@ -44,6 +45,12 @@ func NewRouter(h Handlers, auth gin.HandlerFunc) *gin.Engine {
|
|||||||
protected.GET("/chats/:chat_id", h.Chat.Get)
|
protected.GET("/chats/:chat_id", h.Chat.Get)
|
||||||
protected.POST("/chats/:chat_id/messages", h.Message.Create)
|
protected.POST("/chats/:chat_id/messages", h.Message.Create)
|
||||||
protected.GET("/chats/:chat_id/messages", h.Message.List)
|
protected.GET("/chats/:chat_id/messages", h.Message.List)
|
||||||
|
|
||||||
|
if h.Attachment != nil {
|
||||||
|
protected.POST("/chats/:chat_id/attachments", h.Attachment.Upload)
|
||||||
|
protected.GET("/attachments/:attachment_id", h.Attachment.Get)
|
||||||
|
protected.GET("/attachments/:attachment_id/content", h.Attachment.Content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
|||||||
Reference in New Issue
Block a user