add request header override option

This commit is contained in:
Jun Kurihara 2022-07-06 17:40:45 +09:00
commit b0a9b6b5f8
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
10 changed files with 104 additions and 18 deletions

View file

@ -1,8 +1,14 @@
use super::toml::{ConfigToml, ReverseProxyOption};
use crate::{backend::*, constants::*, error::*, globals::*, log::*};
use crate::{
constants::*,
error::*,
globals::*,
log::*,
proxy::{Backend, Backends, ReverseProxy, Upstream, UpstreamOption},
};
use clap::Arg;
use parking_lot::Mutex;
use rustc_hash::FxHashMap as HashMap;
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
use std::net::SocketAddr;
// #[cfg(feature = "tls")]
@ -165,7 +171,18 @@ fn get_reverse_proxy(rp_settings: &[ReverseProxyOption]) -> Result<ReverseProxy>
uri: rpo.upstream.iter().map(|x| x.to_uri().unwrap()).collect(),
cnt: Default::default(),
lb: Default::default(),
opts: {
if let Some(opts) = &rpo.upstream_options {
opts
.iter()
.filter_map(|str| UpstreamOption::try_from(str.as_str()).ok())
.collect::<HashSet<UpstreamOption>>()
} else {
Default::default()
}
},
};
if rpo.path.is_some() {
upstream.insert(rpo.path.as_ref().unwrap().to_owned(), elem);
} else {