Generic request body (#22)

Fixes #21
This commit is contained in:
David Pedersen
2021-06-19 12:50:33 +02:00
committed by GitHub
parent 6a16cd40ca
commit 356f1c8424
20 changed files with 692 additions and 401 deletions
+5 -2
View File
@@ -13,6 +13,9 @@
//! socket.send(msg).await.unwrap();
//! }
//! }
//! # async {
//! # hyper::Server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
//! # };
//! ```
use crate::{
@@ -41,7 +44,7 @@ pub mod future;
/// each connection.
///
/// See the [module docs](crate::ws) for more details.
pub fn ws<F, Fut>(callback: F) -> OnMethod<BoxResponseBody<WebSocketUpgrade<F>>, EmptyRouter>
pub fn ws<F, Fut, B>(callback: F) -> OnMethod<BoxResponseBody<WebSocketUpgrade<F>, B>, EmptyRouter>
where
F: FnOnce(WebSocket) -> Fut + Clone + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
@@ -50,7 +53,7 @@ where
callback,
config: WebSocketConfig::default(),
};
crate::service::get(svc)
crate::service::get::<_, B>(svc)
}
/// [`Service`] that ugprades connections to websockets and spawns a task to