From 62ddb7ebaef5aff39f4bf8c0d60906e8151b3cae Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Fri, 21 Jun 2024 10:02:15 -0700 Subject: Move adding ResponseCompression module logic to init_downstream_modules So that users can override this behavior. --- pingora-proxy/src/lib.rs | 4 ---- pingora-proxy/src/proxy_trait.rs | 10 ++++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'pingora-proxy') diff --git a/pingora-proxy/src/lib.rs b/pingora-proxy/src/lib.rs index d89cb4a..99e7d6d 100644 --- a/pingora-proxy/src/lib.rs +++ b/pingora-proxy/src/lib.rs @@ -766,10 +766,6 @@ where SV: ProxyHttp, { let mut proxy = HttpProxy::new(inner, conf.clone()); - // Add disabled downstream compression module by default - proxy - .downstream_modules - .add_module(ResponseCompressionBuilder::enable(0)); proxy.handle_init_modules(); Service::new(name.to_string(), proxy) } diff --git a/pingora-proxy/src/proxy_trait.rs b/pingora-proxy/src/proxy_trait.rs index 3b83fda..2d99567 100644 --- a/pingora-proxy/src/proxy_trait.rs +++ b/pingora-proxy/src/proxy_trait.rs @@ -42,8 +42,14 @@ pub trait ProxyHttp { /// Set up downstream modules. /// - /// In this phase, users can add or configure modules before the server starts up. - fn init_downstream_modules(&self, _modules: &mut HttpModules) {} + /// In this phase, users can add or configure [HttpModules] before the server starts up. + /// + /// In the default implementation of this method, [ResponseCompressionBuilder] is added + /// and disabled. + fn init_downstream_modules(&self, modules: &mut HttpModules) { + // Add disabled downstream compression module by default + modules.add_module(ResponseCompressionBuilder::enable(0)); + } /// Handle the incoming request. /// -- cgit v1.2.3