Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Access to fiber.Ctx #94

Open
GarryGaller opened this issue Feb 20, 2022 · 3 comments
Open

Access to fiber.Ctx #94

GarryGaller opened this issue Feb 20, 2022 · 3 comments
Labels
🤔 Question Further information is requested

Comments

@GarryGaller
Copy link

How to access c.Locals ( where c is *fiber.Ctx) from a custom the websocket handler?

@ReneWerner87 ReneWerner87 added the 🤔 Question Further information is requested label Feb 20, 2022
@ReneWerner87
Copy link
Member

@GarryGaller
Copy link
Author

GarryGaller commented Feb 20, 2022

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.

@Bastardly
Copy link

Bastardly commented Mar 30, 2022

@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)
	})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤔 Question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants