diff --git a/core/http/app.go b/core/http/app.go index 19d3eb40..c4a1eafc 100644 --- a/core/http/app.go +++ b/core/http/app.go @@ -88,6 +88,15 @@ func API(application *application.Application) (*fiber.App, error) { router := fiber.New(fiberCfg) + router.Use(func(c *fiber.Ctx) error { + if websocket.IsWebSocketUpgrade(c) { + // Returns true if the client requested upgrade to the WebSocket protocol + return c.Next() + } + + return nil + }) + router.Hooks().OnListen(func(listenData fiber.ListenData) error { scheme := "http" if listenData.TLS { @@ -180,26 +189,6 @@ func API(application *application.Application) (*fiber.App, error) { Browse: true, })) - app.Use(func(c *fiber.Ctx) error { - if websocket.IsWebSocketUpgrade(c) { - // Returns true if the client requested upgrade to the WebSocket protocol - c.Next() - } - - return nil - }) - - // app.Use("/v1/realtime", func(c *fiber.Ctx) error { - // fmt.Println("Hit upgrade from http") - // // IsWebSocketUpgrade returns true if the client - // // requested upgrade to the WebSocket protocol. - // if websocket.IsWebSocketUpgrade(c) { - // c.Locals("allowed", true) - // return c.Next() - // } - // return fiber.ErrUpgradeRequired - // }) - // Define a custom 404 handler // Note: keep this at the bottom! router.Use(notFoundHandler)