use super::*;
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct ExactRewriteRule {
pub(crate) from: String,
pub(crate) to: String,
#[get(type(copy))]
pub(crate) action: RewriteAction,
#[get(type(copy))]
pub(crate) preserve_query: bool,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct PrefixRewriteRule {
pub(crate) from: String,
pub(crate) to: String,
#[get(type(copy))]
pub(crate) action: RewriteAction,
#[get(type(copy))]
pub(crate) preserve_query: bool,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct RegexRewriteRule {
pub(crate) pattern: String,
pub(crate) replacement: String,
#[get(type(copy))]
pub(crate) action: RewriteAction,
#[get(type(copy))]
pub(crate) preserve_query: bool,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct RewriteConfig {
#[get(type(copy))]
pub(crate) force_https: bool,
#[get(type(clone))]
pub(crate) canonical_host: Option<String>,
#[get(type(copy))]
pub(crate) canonical_redirect_status: RedirectStatus,
#[get(type(copy))]
pub(crate) trust_forwarded_proto: bool,
#[get(type(copy))]
pub(crate) collapse_duplicate_slashes: bool,
#[get(type(copy))]
pub(crate) trailing_slash: TrailingSlashMode,
#[get(type(copy))]
pub(crate) normalization_action: RewriteAction,
pub(crate) exact_rules: Vec<ExactRewriteRule>,
pub(crate) prefix_rules: Vec<PrefixRewriteRule>,
pub(crate) regex_rules: Vec<RegexRewriteRule>,
}
#[derive(Clone, Debug)]
pub(crate) struct CompiledExactTarget {
pub(crate) to: String,
pub(crate) action: RewriteAction,
pub(crate) preserve_query: bool,
}
#[derive(Clone, Debug)]
pub(crate) struct CompiledPrefixRule {
pub(crate) from: String,
pub(crate) to: String,
pub(crate) action: RewriteAction,
pub(crate) preserve_query: bool,
}
#[derive(Clone, Debug)]
pub(crate) struct CompiledRegexRule {
pub(crate) regex: Regex,
pub(crate) replacement: String,
pub(crate) action: RewriteAction,
pub(crate) preserve_query: bool,
}
#[derive(Clone, Debug)]
pub struct CompiledRewrite {
pub(crate) config: RewriteConfig,
pub(crate) canonical_host_lower: Option<String>,
pub(crate) exact_map: HashMapXxHash3_64<String, CompiledExactTarget>,
pub(crate) prefix_rules: Vec<CompiledPrefixRule>,
pub(crate) regex_rules: Vec<CompiledRegexRule>,
}
#[derive(Clone, Debug)]
pub struct RewritePlugin {
pub(crate) compiled: CompiledRewrite,
}
#[derive(Clone, Copy, Debug, Default)]
#[hyperlane::request_middleware(-102)]
pub struct RewriteHook;