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

How change websocket connection to function. so i can use function in route #107

Open
ahmadsukabul opened this issue Apr 4, 2022 · 1 comment

Comments

@ahmadsukabul
Copy link

app.Get("/ws/:id", websocket.New(func(c *websocket.Conn) { // c.Locals is added to the *websocket.Conn log.Println(c.Locals("allowed")) // true log.Println(c.Params("id")) // 123 log.Println(c.Query("v")) // 1.0 log.Println(c.Cookies("session")) // "" }))
add this code in function like
func Ws(c *fiber.Ctx) error { //add websocket.New(func(c *websocket.Conn) herre return nil }

so in routes i can use
app.Get("/", Ws)

@ahmadsukabul ahmadsukabul changed the title How change websocket connection to function. so i can use function in controller How change websocket connection to function. so i can use function in route Apr 4, 2022
@idc77
Copy link

idc77 commented Feb 15, 2023

It's very hard to read what your question is.

As I understand you want to use func(c *fiber.Ctx) instead of func(c *websocket.Conn)
I don't think you can do it like this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants