-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathchat.go
35 lines (28 loc) · 951 Bytes
/
chat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package routes
import (
"net/http"
"github.com/go-chi/chi"
"github.com/stakwork/sphinx-tribes/auth"
"github.com/stakwork/sphinx-tribes/db"
"github.com/stakwork/sphinx-tribes/handlers"
)
func ChatRoutes() chi.Router {
r := chi.NewRouter()
chatHandler := handlers.NewChatHandler(http.DefaultClient, db.DB)
r.Post("/response", chatHandler.ProcessChatResponse)
r.Group(func(r chi.Router) {
r.Use(auth.PubKeyContext)
r.Get("/", chatHandler.GetChat)
r.Post("/", chatHandler.CreateChat)
r.Put("/{chat_id}", chatHandler.UpdateChat)
r.Put("/{chat_id}/archive", chatHandler.ArchiveChat)
r.Post("/send", chatHandler.SendMessage)
r.Get("/history/{uuid}", chatHandler.GetChatHistory)
r.Post("/send/build", chatHandler.SendBuildMessage)
r.Post("/upload", chatHandler.UploadFile)
r.Get("/file/{id}", chatHandler.GetFile)
r.Get("/file/all", chatHandler.ListFiles)
r.Delete("/file/{id}", chatHandler.DeleteFile)
})
return r
}