From b61aa20709743fb2aa4aa2ee7146427f591d9bbb Mon Sep 17 00:00:00 2001 From: Tony Dong Date: Sat, 30 Nov 2024 13:59:22 +0800 Subject: [PATCH] feat: Add `apply_interceptor` method for additional service configuration This commit introduces the `apply_interceptor` method, which allows for additional configuration options like `accept_compressed`, `send_compressed`, `max_decoding_message_size`, and `max_encoding_message_size` when applying an interceptor. - The new method provides flexibility for users needing more control over service configuration. - The existing `with_interceptor` method remains unchanged to maintain backward compatibility. --- tonic-build/src/server.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tonic-build/src/server.rs b/tonic-build/src/server.rs index e2d0aacd9..8fcacbdf4 100644 --- a/tonic-build/src/server.rs +++ b/tonic-build/src/server.rs @@ -141,6 +141,13 @@ pub(crate) fn generate_internal( InterceptedService::new(Self::new(inner), interceptor) } + pub fn apply_interceptor(service: Self, interceptor: F) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(service, interceptor) + } + #configure_compression_methods #configure_max_message_size_methods