Skip to content

Commit 22d3fd2

Browse files
committed
setup ws upgrade
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 18592ae commit 22d3fd2

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

core/http/app.go

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ func App(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfig *confi
8989

9090
app := fiber.New(fiberCfg)
9191

92+
app.Use(func(c *fiber.Ctx) error {
93+
if websocket.IsWebSocketUpgrade(c) {
94+
// Returns true if the client requested upgrade to the WebSocket protocol
95+
return c.Next()
96+
}
97+
98+
return nil
99+
})
100+
92101
app.Hooks().OnListen(func(listenData fiber.ListenData) error {
93102
scheme := "http"
94103
if listenData.TLS {
@@ -181,26 +190,6 @@ func App(cl *config.BackendConfigLoader, ml *model.ModelLoader, appConfig *confi
181190
Browse: true,
182191
}))
183192

184-
app.Use(func(c *fiber.Ctx) error {
185-
if websocket.IsWebSocketUpgrade(c) {
186-
// Returns true if the client requested upgrade to the WebSocket protocol
187-
c.Next()
188-
}
189-
190-
return nil
191-
})
192-
193-
// app.Use("/v1/realtime", func(c *fiber.Ctx) error {
194-
// fmt.Println("Hit upgrade from http")
195-
// // IsWebSocketUpgrade returns true if the client
196-
// // requested upgrade to the WebSocket protocol.
197-
// if websocket.IsWebSocketUpgrade(c) {
198-
// c.Locals("allowed", true)
199-
// return c.Next()
200-
// }
201-
// return fiber.ErrUpgradeRequired
202-
// })
203-
204193
// Define a custom 404 handler
205194
// Note: keep this at the bottom!
206195
app.Use(notFoundHandler)

0 commit comments

Comments
 (0)