diff options
author | Yuchen Wu <[email protected]> | 2024-06-21 10:02:15 -0700 |
---|---|---|
committer | Edward Wang <[email protected]> | 2024-06-28 12:34:25 -0700 |
commit | 62ddb7ebaef5aff39f4bf8c0d60906e8151b3cae (patch) | |
tree | e9961e8db4ac2cb133c22ab05177100f9ad73053 | |
parent | dda7bec58cb176228b8194e97c8c9e52bf36b878 (diff) | |
download | pingora-62ddb7ebaef5aff39f4bf8c0d60906e8151b3cae.tar.gz pingora-62ddb7ebaef5aff39f4bf8c0d60906e8151b3cae.zip |
Move adding ResponseCompression module logic to init_downstream_modules
So that users can override this behavior.
-rw-r--r-- | .bleep | 2 | ||||
-rw-r--r-- | pingora-proxy/src/lib.rs | 4 | ||||
-rw-r--r-- | pingora-proxy/src/proxy_trait.rs | 10 |
3 files changed, 9 insertions, 7 deletions
@@ -1 +1 @@ -72328c4a1aec58a40b70f82d1144f70c9a19f207
\ No newline at end of file +cab68d4c24c82270ceffef312efc99a3bbc8aaa9
\ No newline at end of file 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. /// |