Florian Thelliez
d9a06ef14b
Remove axum::prelude ( #195 )
2021-08-18 00:04:15 +02:00
Grzegorz Baranski
4792d0c15c
Make ws::Message an enum for easier frame type matching ( #116 )
...
* feat(ws): make Message an enum to allow pattern matching
* fix(examples): update to new websockets `Message`
* fix(ws): remove wildcard imports
* fix(examples/chat): apply clippy's never_loop
* style: `cargo fmt`
* docs:add license notes above parts that are copied
* fix(ws): make CloseCode an alias to u16
* fix: move Message from src/ws/mod.rs to src/extract/ws.rs
* docs: add changelog entry about websocket messages
* fix: remove useless convertions to the same type
2021-08-07 19:47:22 +02:00
David Pedersen
4194cf70da
Change WebSocket API to use an extractor ( #121 )
...
Fixes https://github.com/tokio-rs/axum/issues/111
Example usage:
```rust
use axum::{
prelude::*,
extract::ws::{WebSocketUpgrade, WebSocket},
response::IntoResponse,
};
let app = route("/ws", get(handler));
async fn handler(ws: WebSocketUpgrade) -> impl IntoResponse {
ws.on_upgrade(handle_socket)
}
async fn handle_socket(mut socket: WebSocket) {
while let Some(msg) = socket.recv().await {
let msg = if let Ok(msg) = msg {
msg
} else {
// client disconnected
return;
};
if socket.send(msg).await.is_err() {
// client disconnected
return;
}
}
}
```
2021-08-07 17:26:23 +02:00
David Pedersen
5c12328892
Replace hyper::Server with axum::Server in docs ( #118 )
...
* Replace `hyper::Server` with `axum::Server` in docs
* Change readme as well
2021-08-04 15:38:51 +02:00
Grzegorz Baranski
4e9b38ddf9
Use tuple destructuring in chat example ( #105 )
2021-08-03 22:21:18 +02:00
David Pedersen
9fbababc3a
Make it clear how to run all examples ( #92 )
...
* Handle errors in websocket example
* Make it clear how to run all examples
2021-08-02 23:09:09 +02:00
Javier Viola
c6b7ad0f33
Add chat example documentation. ( #85 )
2021-08-02 21:42:10 +02:00
programatik29
ffefb3455c
Add chat example ( #78 )
2021-08-01 22:42:34 +02:00