mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-09 00:00:12 +02:00
Add support for websockets (#3)
Basically a copy/paste of whats in warp.
Example usage:
```rust
use tower_web::{prelude::*, ws::{ws, WebSocket}};
let app = route("/ws", ws(handle_socket));
async fn handle_socket(mut socket: WebSocket) {
while let Some(msg) = socket.recv().await {
let msg = msg.unwrap();
socket.send(msg).await.unwrap();
}
}
```
This commit is contained in:
+20
-1
@@ -12,6 +12,9 @@ readme = "README.md"
|
||||
repository = "https://github.com/davidpdrsn/tower-web"
|
||||
version = "0.1.0"
|
||||
|
||||
[features]
|
||||
ws = ["tokio-tungstenite", "sha-1", "base64"]
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1"
|
||||
bytes = "1.0"
|
||||
@@ -28,16 +31,32 @@ tokio = { version = "1", features = ["time"] }
|
||||
tower = { version = "0.4", features = ["util", "buffer"] }
|
||||
tower-http = { version = "0.1", features = ["add-extension"] }
|
||||
|
||||
# optional dependencies
|
||||
tokio-tungstenite = { optional = true, version = "0.14" }
|
||||
sha-1 = { optional = true, version = "0.9.6" }
|
||||
base64 = { optional = true, version = "0.13" }
|
||||
|
||||
[dev-dependencies]
|
||||
hyper = { version = "0.14", features = ["full"] }
|
||||
reqwest = { version = "0.11", features = ["json", "stream"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tokio = { version = "1.6.1", features = ["macros", "rt", "rt-multi-thread"] }
|
||||
tower = { version = "0.4", features = ["util", "make", "timeout", "limit", "load-shed", "steer"] }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.2"
|
||||
uuid = "0.8"
|
||||
|
||||
[dev-dependencies.tower]
|
||||
version = "0.4"
|
||||
features = [
|
||||
"util",
|
||||
"make",
|
||||
"timeout",
|
||||
"limit",
|
||||
"load-shed",
|
||||
"steer",
|
||||
"filter",
|
||||
]
|
||||
|
||||
[dev-dependencies.tower-http]
|
||||
version = "0.1"
|
||||
features = [
|
||||
|
||||
Reference in New Issue
Block a user