1use crate::core::config::{Config, ContextPolicy};
5
6pub struct ProxyRunOptions {
8 pub listen: String,
9 pub upstream: String,
10 pub minify_json: bool,
11 pub compress_transport: bool,
12 pub max_response_bytes: u64,
13 pub max_request_bytes: u64,
14 pub context_policy: ContextPolicy,
15}
16
17impl ProxyRunOptions {
18 pub fn from_config(cfg: &Config) -> Self {
19 let p = &cfg.proxy;
20 Self {
21 listen: p.listen.clone(),
22 upstream: p.upstream.clone(),
23 minify_json: p.minify_json,
24 compress_transport: p.compress_transport,
25 max_response_bytes: u64::from(p.max_response_body_mb) * 1024 * 1024,
26 max_request_bytes: u64::from(p.max_request_body_mb) * 1024 * 1024,
27 context_policy: p.context_policy.clone(),
28 }
29 }
30
31 pub fn from_config_with_overrides(
33 cfg: &Config,
34 listen: Option<String>,
35 upstream: Option<String>,
36 ) -> Self {
37 let mut o = Self::from_config(cfg);
38 if let Some(s) = listen {
39 o.listen = s;
40 }
41 if let Some(s) = upstream {
42 o.upstream = s;
43 }
44 o
45 }
46}