myc_http_tools/settings.rs
1use lazy_static::lazy_static;
2use std::env::var_os;
3use zstd::DEFAULT_COMPRESSION_LEVEL as ZSTD_DEFAULT_COMPRESSION_LEVEL;
4
5// ? ---------------------------------------------------------------------------
6// ? Configure default system constants
7// ? ---------------------------------------------------------------------------
8
9/// Default profile key
10///
11/// This is the default key used to store the profile in the request headers and
12/// send it to the gateway downstream services.
13///
14pub const DEFAULT_PROFILE_KEY: &str = "x-mycelium-profile";
15
16/// Default email key
17///
18/// This is the default key used to store the email in the request headers and
19/// send it to the gateway downstream services.
20///
21pub const DEFAULT_EMAIL_KEY: &str = "x-mycelium-email";
22
23/// Default scope key
24///
25/// The scope key should be used to inject the scope present on the connection
26/// string into the request headers and send it to the gateway downstream
27/// services.
28///
29pub const DEFAULT_SCOPE_KEY: &str = "x-mycelium-scope";
30
31/// Default mycelium role key
32///
33/// This is the default key used to store the mycelium role in the request
34/// headers and send it to the gateway downstream services.
35///
36pub const DEFAULT_MYCELIUM_ROLE_KEY: &str = "x-mycelium-role";
37
38/// Default request id key
39///
40/// This is the default key used to store the request id in the request headers
41/// and send it to the gateway downstream services.
42///
43pub const DEFAULT_REQUEST_ID_KEY: &str = "x-mycelium-request-id";
44
45/// Default connection string key
46///
47/// This is the default key used to store the connection string in the request
48/// headers and send it to the gateway downstream services.
49///
50pub const DEFAULT_CONNECTION_STRING_KEY: &str = "x-mycelium-connection-string";
51
52/// Default tenant id key
53///
54/// This is the default key used to store the tenant id in the request headers
55/// and send it to the gateway downstream services.
56///
57pub const DEFAULT_TENANT_ID_KEY: &str = "x-mycelium-tenant-id";
58
59/// Default forward header key
60///
61/// This is the default key used to store the forward header in the request
62/// headers and send it to the gateway downstream services.
63///
64pub const FORWARD_FOR_KEY: &str = "x-forwarded-for";
65
66/// Default forwarded keys
67///
68/// This is the default key used to store the forwarded host, protocol and port
69/// in the request headers and send it to the gateway downstream services.
70///
71pub const MYCELIUM_SERVICE_NAME: &str = "x-mycelium-service-name";
72
73/// Default security group key
74///
75/// This is the default key used to store the security group in the request
76/// headers and send it to the gateway downstream services.
77///
78pub const MYCELIUM_SECURITY_GROUP: &str = "x-mycelium-security-group";
79
80/// Default forwarding keys
81///
82/// Such keys are used to map the headers that should be removed from the
83/// downstream response before stream it back to the client.
84///
85pub const FORWARDING_KEYS: [&str; 9] = [
86 "Host",
87 "Connection",
88 "Keep-Alive",
89 "Proxy-Authenticate",
90 "Proxy-Authorization",
91 "Te",
92 "Trailers",
93 "Transfer-Encoding",
94 "Upgrade",
95];
96
97/// Mycelium provider key
98///
99/// This is the key used to indicate that the request is coming from the
100/// internal provider. This key should be used to validate the issuer of the
101/// request.
102///
103pub const MYCELIUM_PROVIDER_KEY: &str = "mycelium";
104
105/// The scope used to indicate MCP routes
106pub const MYCELIUM_AI_AWARE: &str = "mycelium-ai-aware";
107
108/// Default compression level
109///
110/// This is the default compression level used to compress the profile before
111/// encoding to Base64.
112///
113pub const DEFAULT_COMPRESSION_LEVEL: i32 = ZSTD_DEFAULT_COMPRESSION_LEVEL;
114
115// ? ---------------------------------------------------------------------------
116// ? Authentication and authorization
117// ? ---------------------------------------------------------------------------
118
119lazy_static! {
120 #[derive(Debug)]
121 pub(crate) static ref PROFILE_FETCHING_URL: String =
122 match var_os("PROFILE_FETCHING_URL") {
123 Some(path) => path.into_string().unwrap(),
124 None => panic!("PROFILE_FETCHING_URL not configured."),
125 };
126}