Skip to content

Commit

Permalink
chore: Rename Status to_http method to into_http (#1719)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Jun 12, 2024
1 parent ed95d27 commit 3e5cd1e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tonic/src/server/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ macro_rules! t {
($result:expr) => {
match $result {
Ok(value) => value,
Err(status) => return status.to_http(),
Err(status) => return status.into_http(),
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions tonic/src/service/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ where
let response = status
.take()
.unwrap()
.to_http()
.into_http()
.map(|_| B::default())
.map(boxed);
Poll::Ready(Ok(response))
Expand Down Expand Up @@ -288,7 +288,7 @@ mod tests {
#[tokio::test]
async fn handles_intercepted_status_as_response() {
let message = "Blocked by the interceptor";
let expected = Status::permission_denied(message).to_http();
let expected = Status::permission_denied(message).into_http();

let svc = tower::service_fn(|_: http::Request<TestBody>| async {
Ok::<_, Status>(http::Response::new(TestBody))
Expand Down
3 changes: 1 addition & 2 deletions tonic/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,8 @@ impl Status {
self
}

#[allow(clippy::wrong_self_convention)]
/// Build an `http::Response` from the given `Status`.
pub fn to_http(self) -> http::Response<BoxBody> {
pub fn into_http(self) -> http::Response<BoxBody> {
let mut response = http::Response::new(crate::body::empty_body());
response.headers_mut().insert(
http::header::CONTENT_TYPE,
Expand Down

0 comments on commit 3e5cd1e

Please sign in to comment.