summaryrefslogtreecommitdiff
path: root/srv/api/api.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2021-08-30 20:08:51 -0600
committerBrian Picciano <mediocregopher@gmail.com>2021-08-30 20:44:45 -0600
commit9343d2ea697f13e52e9199fce62a959f1954f580 (patch)
treee1e36e330a3c9891bfd8a625229a9b417ad89afa /srv/api/api.go
parent3e9a17abb9a9d63af3c260fba9dc404dd9c59ade (diff)
add chat handlers and only allow POST methods
Diffstat (limited to 'srv/api/api.go')
-rw-r--r--srv/api/api.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/srv/api/api.go b/srv/api/api.go
index bbb677a..6ba7ce0 100644
--- a/srv/api/api.go
+++ b/srv/api/api.go
@@ -26,7 +26,7 @@ type Params struct {
PowManager pow.Manager
MailingList mailinglist.MailingList
GlobalRoom chat.Room
- UserIDCalculator chat.UserIDCalculator
+ UserIDCalculator *chat.UserIDCalculator
// ListenProto and ListenAddr are passed into net.Listen to create the
// API's listener. Both "tcp" and "unix" protocols are explicitly
@@ -165,7 +165,14 @@ func (a *api) handler() http.Handler {
apiMux.Handle("/mailinglist/finalize", a.mailingListFinalizeHandler())
apiMux.Handle("/mailinglist/unsubscribe", a.mailingListUnsubscribeHandler())
+ apiMux.Handle("/chat/global/", http.StripPrefix("/chat/global", newChatHandler(
+ a.params.GlobalRoom,
+ a.params.UserIDCalculator,
+ a.requirePowMiddleware,
+ )))
+
var apiHandler http.Handler = apiMux
+ apiHandler = allowedMethod("POST", apiHandler)
apiHandler = checkCSRFMiddleware(apiHandler)
apiHandler = logMiddleware(a.params.Logger, apiHandler)
apiHandler = annotateMiddleware(apiHandler)