Reduce size of response body types (#11)

Wrapping everything in `crate::body::Either` wasn't actually necessary
ans probably causes large body types. You can instead box the bodies in
the leaf services.
This commit is contained in:
David Pedersen
2021-06-13 10:10:37 +02:00
committed by GitHub
parent 7a051eb2d0
commit 59944c231f
6 changed files with 126 additions and 189 deletions
+5 -2
View File
@@ -15,7 +15,10 @@
//! }
//! ```
use crate::{routing::EmptyRouter, service::OnMethod};
use crate::{
routing::EmptyRouter,
service::{BoxResponseBody, OnMethod},
};
use bytes::Bytes;
use future::ResponseFuture;
use futures_util::{sink::SinkExt, stream::StreamExt};
@@ -38,7 +41,7 @@ pub mod future;
/// each connection.
///
/// See the [module docs](crate::ws) for more details.
pub fn ws<F, Fut>(callback: F) -> OnMethod<WebSocketUpgrade<F>, EmptyRouter>
pub fn ws<F, Fut>(callback: F) -> OnMethod<BoxResponseBody<WebSocketUpgrade<F>>, EmptyRouter>
where
F: FnOnce(WebSocket) -> Fut + Clone + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,