aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-05-31 21:27:38 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-05-31 21:29:00 +0200
commit0d0b416146dd146a5dcfbf61f09f8136aa5afdc2 (patch)
tree3208eb54f4ec1bba5a8e189a939be4e89330c67f
parent2a16dcba5a31a45a12853a15254719c357baae6d (diff)
downloadWRMS-0d0b416146dd146a5dcfbf61f09f8136aa5afdc2.tar.gz
WRMS-0d0b416146dd146a5dcfbf61f09f8136aa5afdc2.zip
create websocket context after successfully identifying the connection
Fixes: d8bdce51c336f3693121202402ee38ff3f12c0e2
-rw-r--r--main.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/main.go b/main.go
index 53dc440..8ff3a81 100644
--- a/main.go
+++ b/main.go
@@ -201,10 +201,6 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) {
return
}
- ctx, cancel := context.WithCancel(r.Context())
-
- ctx = c.CloseRead(ctx)
-
uuidCookie, err := r.Cookie("UUID")
if err != nil {
llog.Error("websocket connection has no set UUID cookie")
@@ -219,6 +215,9 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) {
return
}
+ ctx, cancel := context.WithCancel(r.Context())
+ ctx = c.CloseRead(ctx)
+
defer func() {
llog.Info("cancel context of connection %v", id)
cancel()