+ // websocat ws://127.0.0.1:3030/ws-echo
+ let echo = warp::path("ws-echo")
+ .and(warp::ws())
+ .map(|ws: warp::ws::Ws| {
+ ws.on_upgrade(|websocket| {
+ // echo all messages back
+ let (tx, rx) = websocket.split();
+ rx.forward(tx).map(|result| {
+ if let Err(e) = result {
+ eprintln!("websocket error: {:?}", e);
+ }
+ })
+ })
+ });
+
+ warp::serve(hello.or(echo))