Skip to content

Commit e199387

Browse files
authored
fix(web): fix compilation (#670)
Make tonic::body::empty_body public and use it instead of the old and non existant anymore BoxBody::empty()
1 parent 9cc14b7 commit e199387

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

tonic-web/tonic-web/src/service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::task::{Context, Poll};
22

33
use http::{header, HeaderMap, HeaderValue, Method, Request, Response, StatusCode, Version};
44
use hyper::Body;
5-
use tonic::body::BoxBody;
5+
use tonic::body::{BoxBody, empty_body};
66
use tonic::transport::NamedService;
77
use tower_service::Service;
88
use tracing::{debug, trace};
@@ -65,7 +65,7 @@ where
6565
fn no_content(&self, headers: HeaderMap) -> BoxFuture<S::Response, S::Error> {
6666
let mut res = Response::builder()
6767
.status(StatusCode::NO_CONTENT)
68-
.body(BoxBody::empty())
68+
.body(empty_body())
6969
.unwrap();
7070

7171
res.headers_mut().extend(headers);
@@ -77,7 +77,7 @@ where
7777
Box::pin(async move {
7878
Ok(Response::builder()
7979
.status(status)
80-
.body(BoxBody::empty())
80+
.body(empty_body())
8181
.unwrap())
8282
})
8383
}

tonic/src/body.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub type BoxBody = http_body::combinators::BoxBody<bytes::Bytes, crate::Status>;
77

88
// this also exists in `crate::codegen` but we need it here since `codegen` has
99
// `#[cfg(feature = "codegen")]`.
10-
pub(crate) fn empty_body() -> BoxBody {
10+
/// Create an empty `BoxBody`
11+
pub fn empty_body() -> BoxBody {
1112
http_body::Empty::new().map_err(|err| match err {}).boxed()
1213
}

0 commit comments

Comments
 (0)