Open ahmadsukabul opened 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 }
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")) // "" }))
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)
app.Get("/", Ws)
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.
func(c *fiber.Ctx)
func(c *websocket.Conn)
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 likefunc Ws(c *fiber.Ctx) error { //add websocket.New(func(c *websocket.Conn) herre return nil }
so in routes i can use
app.Get("/", Ws)