1const DEFAULT_BODY_LIMIT: usize = 10 * 1024 * 1024;
2
3#[non_exhaustive]
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct RustAuthAxumOptions {
7 pub(crate) body_limit: usize,
8 pub(crate) use_connect_info_for_ip: bool,
9 pub(crate) infer_base_url_from_request: bool,
10 pub(crate) trust_proxy_headers_for_base_url: bool,
11}
12
13impl RustAuthAxumOptions {
14 pub fn new() -> Self {
15 Self::default()
16 }
17
18 #[must_use]
19 pub fn body_limit(mut self, body_limit: usize) -> Self {
20 self.body_limit = body_limit;
21 self
22 }
23
24 #[must_use]
25 pub fn use_connect_info_for_ip(mut self, enabled: bool) -> Self {
26 self.use_connect_info_for_ip = enabled;
27 self
28 }
29
30 #[must_use]
31 pub fn infer_base_url_from_request(mut self, enabled: bool) -> Self {
32 self.infer_base_url_from_request = enabled;
33 self
34 }
35
36 #[must_use]
37 pub fn trust_proxy_headers_for_base_url(mut self, enabled: bool) -> Self {
38 self.trust_proxy_headers_for_base_url = enabled;
39 self
40 }
41}
42
43impl Default for RustAuthAxumOptions {
44 fn default() -> Self {
45 Self {
46 body_limit: DEFAULT_BODY_LIMIT,
47 use_connect_info_for_ip: true,
48 infer_base_url_from_request: false,
49 trust_proxy_headers_for_base_url: false,
50 }
51 }
52}