heart

Function ws

Source
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 be upgrade
  • Header upgrade must be websocket
  • Header sec-websocket-version must be 13
  • 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.