Skip to content

Commit

Permalink
Move adding ResponseCompression module logic to init_downstream_modules
Browse files Browse the repository at this point in the history
So that users can override this behavior.
  • Loading branch information
eaufavor authored and drcaramelsyrup committed Jun 28, 2024
1 parent dda7bec commit 62ddb7e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72328c4a1aec58a40b70f82d1144f70c9a19f207
cab68d4c24c82270ceffef312efc99a3bbc8aaa9
4 changes: 0 additions & 4 deletions pingora-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
10 changes: 8 additions & 2 deletions pingora-proxy/src/proxy_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit 62ddb7e

Please sign in to comment.