gofiber / websocket

⚠️ Deprecated repository, available within Fiber Contrib.
https://github.com/gofiber/contrib/tree/main/websocket
MIT License
289 stars 25 forks source link

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

Open ahmadsukabul opened 2 years ago

ahmadsukabul commented 2 years ago

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)

idc77 commented 1 year ago

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.