Skip to content

Commit afb9df8

Browse files
authored
chore(router): Simplify unimplemented fallback (#2151)
1 parent 6664610 commit afb9df8

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tonic/src/service/router.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::{body::Body, metadata::GRPC_CONTENT_TYPE, server::NamedService, Status};
2-
use http::{HeaderValue, Request, Response};
1+
use crate::{body::Body, server::NamedService, Status};
2+
use http::{Request, Response};
33
use std::{
44
convert::Infallible,
55
fmt,
@@ -135,13 +135,9 @@ impl From<axum::Router> for Routes {
135135
}
136136
}
137137

138-
async fn unimplemented() -> impl axum::response::IntoResponse {
139-
let status = http::StatusCode::OK;
140-
let headers = [
141-
(Status::GRPC_STATUS, HeaderValue::from_static("12")),
142-
(http::header::CONTENT_TYPE, GRPC_CONTENT_TYPE),
143-
];
144-
(status, headers)
138+
async fn unimplemented() -> Response<Body> {
139+
let (parts, ()) = Status::unimplemented("").into_http::<()>().into_parts();
140+
Response::from_parts(parts, Body::empty())
145141
}
146142

147143
impl<B> Service<Request<B>> for Routes

0 commit comments

Comments
 (0)