aboutsummaryrefslogtreecommitdiffhomepage
path: root/pingora-proxy
diff options
context:
space:
mode:
authorYuchen Wu <[email protected]>2024-06-21 10:02:15 -0700
committerEdward Wang <[email protected]>2024-06-28 12:34:25 -0700
commit62ddb7ebaef5aff39f4bf8c0d60906e8151b3cae (patch)
treee9961e8db4ac2cb133c22ab05177100f9ad73053 /pingora-proxy
parentdda7bec58cb176228b8194e97c8c9e52bf36b878 (diff)
downloadpingora-62ddb7ebaef5aff39f4bf8c0d60906e8151b3cae.tar.gz
pingora-62ddb7ebaef5aff39f4bf8c0d60906e8151b3cae.zip
Move adding ResponseCompression module logic to init_downstream_modules
So that users can override this behavior.
Diffstat (limited to 'pingora-proxy')
-rw-r--r--pingora-proxy/src/lib.rs4
-rw-r--r--pingora-proxy/src/proxy_trait.rs10
2 files changed, 8 insertions, 6 deletions
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.
///