Function warp::filters::ws::ws [−][src]
pub fn ws<F, U>(
fun: F
) -> impl FilterClone<Extract = (Ws,), Error = Rejection> where
F: Fn(WebSocket) -> U + Clone + Send + 'static,
U: Future<Item = (), Error = ()> + Send + 'static,
Creates a Websocket Filter.
The passed function is called with each successful Websocket accepted.
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
which will 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.