iris icon indicating copy to clipboard operation
iris copied to clipboard

Websocket handler inside a party

Open ierehon1905 opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. i can not create a ws handler inside party

Describe the solution you'd like ws handler registered inside a party works

Describe alternatives you've considered I managed to register a handler at root level but with path nested as the party

ierehon1905 avatar Jun 26 '23 23:06 ierehon1905

Hello @ierehon1905, can you show us the code snippet you used to do it?

kataras avatar Jul 01 '23 11:07 kataras

Hello,

The following code works (the ws handle)

	app.Get("/api/ws", websocket.Handler(ws))

	api := app.Party("/api")
	{
		api.Use(iris.Compression)
		api.Get("/ping", pingHandler)
		api.Post("/user-session", createUserSessionHandler)
		api.Get("/game/:id", getGameHandler)
		app.Get("/logout", logoutHandler)
	}
image

The following does not

	api := app.Party("/api")
	{
		api.Use(iris.Compression)
		api.Get("/ping", pingHandler)
		api.Post("/user-session", createUserSessionHandler)
		api.Get("/game/:id", getGameHandler)
		app.Get("/logout", logoutHandler)
		app.Get("/ws", websocket.Handler(ws))
	}
image

I use websocket.DefaultGobwasUpgrader to enable CORS.

ierehon1905 avatar Jul 01 '23 12:07 ierehon1905