On Fri, 24 Mar 2017 19:25:38 +0100, Markus wrote:
Hi,
I'am new to vibe.d and are playing around with the chat-server tutorial.
My client uses angular2 and I notice a strange behavior:The /ws or /ws/ websocket endpoint returns a 302. I reduced the code, so
that no addional parameters are needed, but the behavior resists. If I
define the route explizit, everything works as aspected:auto router = new URLRouter;
auto ws = new WebChat;
router.registerWebInterface(ws);
router.get("/ws2/", handleWebSockets(&ws.getWs));The new /ws2/ endpoint works well.
What am I doing wrong?
Regards
Markus
The web interface generator adds convenience redirects for all routes by default (WebInterfaceSettings.ignoreTrailingSlash
), so that a route with path "/foo" can also be accessed as "/foo/" or vice-versa. For web sockets this might be an issue (haven't tested that case yet), but if you particularly need the "/ws/" path be accessible without a redirect, adding an explicit @path("/ws/")
to the getWS
route should achieve that.