aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 61fc747..febe540 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -58,6 +58,18 @@ struct Opt {
/// E-mail address for Let's Encrypt certificate requests
#[structopt(long = "letsencrypt-email", env = "TRICOT_LETSENCRYPT_EMAIL")]
pub letsencrypt_email: String,
+
+ /// Enable compression of responses
+ #[structopt(long = "enable-compression", env = "TRICOT_ENABLE_COMPRESSION")]
+ pub enable_compression: bool,
+
+ /// Mime types for which to enable compression (comma-separated list)
+ #[structopt(
+ long = "compress-mime-types",
+ env = "TRICOT_COMPRESS_MIME_TYPES",
+ default_value = "text/html,text/plain,text/css,text/javascript,application/javascript,image/svg+xml"
+ )]
+ pub compress_mime_types: String,
}
#[tokio::main(flavor = "multi_thread", worker_threads = 10)]
@@ -87,13 +99,19 @@ async fn main() {
);
tokio::spawn(http::serve_http(opt.http_bind_addr, consul.clone()).map_err(exit_on_err));
+
+ let https_config = https::HttpsConfig {
+ bind_addr: opt.https_bind_addr,
+ enable_compression: opt.enable_compression,
+ compress_mime_types: opt
+ .compress_mime_types
+ .split(",")
+ .map(|x| x.to_string())
+ .collect(),
+ };
tokio::spawn(
- https::serve_https(
- opt.https_bind_addr,
- cert_store.clone(),
- rx_proxy_config.clone(),
- )
- .map_err(exit_on_err),
+ https::serve_https(https_config, cert_store.clone(), rx_proxy_config.clone())
+ .map_err(exit_on_err),
);
while rx_proxy_config.changed().await.is_ok() {