forked from mtusi2026/mtusi2026lab3
work 3
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"gitflic.ru/project/relationskatie/mtusi2026lab1-ashchkl/internal/api/http/middleware"
|
||||
)
|
||||
|
||||
func registerRoutes(e *echo.Echo, d Deps, isReady func() bool) {
|
||||
e.GET("/health/live", healthLive)
|
||||
e.GET("/health/ready", healthReady(isReady))
|
||||
|
||||
usersH := &usersHandler{users: d.Users}
|
||||
chatsH := &chatsHandler{chats: d.Chats}
|
||||
messagesH := &messagesHandler{messages: d.Messages}
|
||||
authH := &authHandler{auth: d.Auth}
|
||||
|
||||
auth := middleware.Bearer(d.Auth)
|
||||
|
||||
jsonBody := middleware.ContentType()
|
||||
|
||||
v1 := e.Group("/api/v1")
|
||||
v1.POST("/users", usersH.create, jsonBody)
|
||||
v1.POST("/auth/sessions", authH.createSession)
|
||||
v1.DELETE("/auth/sessions/current", authH.revokeSession, auth)
|
||||
v1.GET("/users/me", usersH.me, auth)
|
||||
v1.POST("/chats", chatsH.create, auth, jsonBody)
|
||||
v1.GET("/chats", chatsH.list, auth)
|
||||
v1.GET("/chats/:chat_id", chatsH.get, auth)
|
||||
v1.POST("/chats/:chat_id/messages", messagesH.send, auth, jsonBody)
|
||||
v1.GET("/chats/:chat_id/messages", messagesH.list, auth)
|
||||
}
|
||||
Reference in New Issue
Block a user