diff --git a/examples/shared/Cargo.toml b/examples/shared/Cargo.toml index 9e6c8a4..bc7cc0e 100644 --- a/examples/shared/Cargo.toml +++ b/examples/shared/Cargo.toml @@ -12,3 +12,6 @@ uuid = { version = "1.10.0" } [build-dependencies] gin-tonic = { version = "0.4.8", features = ["uuid_bytes"] } + +[patch.crates-io] +gin-tonic = { path = "../../gin" } diff --git a/examples/shared/src/example.rs b/examples/shared/src/example.rs index c4856f7..9ef4127 100644 --- a/examples/shared/src/example.rs +++ b/examples/shared/src/example.rs @@ -15,19 +15,17 @@ pub mod example_server { } #[derive(Debug)] pub struct ExampleServer { - inner: _Inner, + inner: Arc, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, max_decoding_message_size: Option, max_encoding_message_size: Option, } - struct _Inner(Arc); impl ExampleServer { pub fn new(inner: T) -> Self { Self::from_arc(Arc::new(inner)) } pub fn from_arc(inner: Arc) -> Self { - let inner = _Inner(inner); Self { inner, accept_compression_encodings: Default::default(), @@ -87,7 +85,6 @@ pub mod example_server { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { - let inner = self.inner.clone(); match req.uri().path() { "/example.Example/echo" => { #[allow(non_camel_case_types)] @@ -110,7 +107,6 @@ pub mod example_server { let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { - let inner = inner.0; let method = echoSvc(inner); let codec = ::gin_tonic::GinCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) @@ -130,8 +126,11 @@ pub mod example_server { _ => Box::pin(async move { Ok(http::Response::builder() .status(200) - .header("grpc-status", "12") - .header("content-type", "application/grpc") + .header("grpc-status", tonic::Code::Unimplemented as i32) + .header( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ) .body(empty_body()) .unwrap()) }), @@ -150,16 +149,6 @@ pub mod example_server { } } } - impl Clone for _Inner { - fn clone(&self) -> Self { - Self(Arc::clone(&self.0)) - } - } - impl std::fmt::Debug for _Inner { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.0) - } - } impl tonic::server::NamedService for ExampleServer { const NAME: &'static str = "example.Example"; }