This patch was authored by @code28 and released by @siemensikkema.
Adds support for a custom implementation of shouldUpgrade
for websockets. This can be used to switch to specific subprotocols or to deny upgrading by returning nil
.
routes.webSocket("authedecho", shouldUpgrade: { req in
guard req.auth.has(User.self) else {
return req.eventLoop.future(nil)
}
return req.eventLoop.future([:])
}, onUpgrade: { req, ws in
print(ws)
})