websocket
websocket copied to clipboard
Access to fiber.Ctx
How to access c.Locals ( where c is *fiber.Ctx) from a custom the websocket handler?
https://github.com/gofiber/websocket/blob/master/README.md#example
Just check the example
This is not the c.Locals object I need. You need ctx.Locals, where cts is fiber.Ctx The c.Locals cannot have a value set. You can only read it.
@GarryGaller I'm not completely sure what you aim to do. But here's an example where I bring fiber.Ctx into scope.
app.Get("/ws/:id", func (ctx *fiber.Ctx) error {
s := getSession(ctx)
handler := websocket.New(func (c *websocket.Conn) {
webSocketHandler(c, s)
})
return handler(ctx)
})