ferron/util/
url_rewrite_structs.rs

1use fancy_regex::Regex;
2
3pub struct UrlRewriteMapEntry {
4  pub regex: Regex,
5  pub replacement: String,
6  pub is_not_directory: bool,
7  pub is_not_file: bool,
8  pub last: bool,
9  pub allow_double_slashes: bool,
10}
11
12impl UrlRewriteMapEntry {
13  pub fn new(
14    regex: Regex,
15    replacement: String,
16    is_not_directory: bool,
17    is_not_file: bool,
18    last: bool,
19    allow_double_slashes: bool,
20  ) -> Self {
21    Self {
22      regex,
23      replacement,
24      is_not_directory,
25      is_not_file,
26      last,
27      allow_double_slashes,
28    }
29  }
30}
31
32pub struct UrlRewriteMapWrap {
33  pub domain: Option<String>,
34  pub ip: Option<String>,
35  pub rewrite_map: Vec<UrlRewriteMapEntry>,
36  pub locations: Vec<UrlRewriteMapLocationWrap>,
37}
38
39impl UrlRewriteMapWrap {
40  pub fn new(
41    domain: Option<String>,
42    ip: Option<String>,
43    rewrite_map: Vec<UrlRewriteMapEntry>,
44    locations: Vec<UrlRewriteMapLocationWrap>,
45  ) -> Self {
46    Self {
47      domain,
48      ip,
49      rewrite_map,
50      locations,
51    }
52  }
53}
54
55pub struct UrlRewriteMapLocationWrap {
56  pub path: String,
57  pub rewrite_map: Vec<UrlRewriteMapEntry>,
58}
59
60impl UrlRewriteMapLocationWrap {
61  pub fn new(path: String, rewrite_map: Vec<UrlRewriteMapEntry>) -> Self {
62    Self { path, rewrite_map }
63  }
64}