Skip to content

Commit

Permalink
chore(router): Simplify unimplemented fallback (#2151)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Jan 18, 2025
1 parent 6664610 commit afb9df8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tonic/src/service/router.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{body::Body, metadata::GRPC_CONTENT_TYPE, server::NamedService, Status};
use http::{HeaderValue, Request, Response};
use crate::{body::Body, server::NamedService, Status};
use http::{Request, Response};
use std::{
convert::Infallible,
fmt,
Expand Down Expand Up @@ -135,13 +135,9 @@ impl From<axum::Router> for Routes {
}
}

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

impl<B> Service<Request<B>> for Routes
Expand Down

0 comments on commit afb9df8

Please sign in to comment.