pub fn ws() -> impl Filter + Copy
Expand description
Creates a Websocket Filter.
The yielded Ws
is used to finish the websocket upgrade.
§Note
This filter combines multiple filters internally, so you don’t need them:
- Method must be
GET
- Header
connection
must beupgrade
- Header
upgrade
must bewebsocket
- Header
sec-websocket-version
must be13
- Header
sec-websocket-key
must be set.
If the filters are met, yields a Ws
. Calling Ws::on_upgrade
will
return a reply with:
- Status of
101 Switching Protocols
- Header
connection: upgrade
- Header
upgrade: websocket
- Header
sec-websocket-accept
with the hash value of the received key.