rust_web_server/entry_point/environment_variables/
mod.rs1#[cfg(test)]
2mod tests;
3
4use std::env;
5use crate::entry_point::Config;
6
7pub fn read_system_environment_variables() {
8 println!(" Start Of System Environment Variables Section");
9
10 let boxed_ip = env::var(Config::RWS_CONFIG_IP);
11 if boxed_ip.is_ok() {
12 println!(" Environment variable '{}' set to value '{}'",
13 Config::RWS_CONFIG_IP,
14 boxed_ip.unwrap());
15 }
16
17 let boxed_port = env::var(Config::RWS_CONFIG_PORT);
18 if boxed_port.is_ok() {
19 println!(" Environment variable '{}' set to value '{}'",
20 Config::RWS_CONFIG_PORT,
21 boxed_port.unwrap());
22 }
23
24 let boxed_request_allocation_size = env::var(Config::RWS_CONFIG_REQUEST_ALLOCATION_SIZE_IN_BYTES);
25 if boxed_request_allocation_size.is_ok() {
26 println!(" Environment variable '{}' set to value '{}'",
27 Config::RWS_CONFIG_REQUEST_ALLOCATION_SIZE_IN_BYTES,
28 boxed_request_allocation_size.unwrap());
29 }
30
31 let boxed_thread_count = env::var(Config::RWS_CONFIG_THREAD_COUNT);
32 if boxed_thread_count.is_ok() {
33 println!(" Environment variable '{}' set to value '{}'",
34 Config::RWS_CONFIG_THREAD_COUNT,
35 boxed_thread_count.unwrap());
36 }
37
38 let boxed_cors_allow_all = env::var(Config::RWS_CONFIG_CORS_ALLOW_ALL);
39 if boxed_cors_allow_all.is_ok() {
40 println!(" Environment variable '{}' set to value '{}'",
41 Config::RWS_CONFIG_CORS_ALLOW_ALL,
42 boxed_cors_allow_all.unwrap());
43 }
44
45 let boxed_cors_allow_origins = env::var(Config::RWS_CONFIG_CORS_ALLOW_ORIGINS);
46 if boxed_cors_allow_origins.is_ok() {
47 println!(" Environment variable '{}' set to value '{}'",
48 Config::RWS_CONFIG_CORS_ALLOW_ORIGINS,
49 boxed_cors_allow_origins.unwrap());
50 }
51
52 let boxed_cors_allow_methods = env::var(Config::RWS_CONFIG_CORS_ALLOW_METHODS);
53 if boxed_cors_allow_methods.is_ok() {
54 println!(" Environment variable '{}' set to value '{}'",
55 Config::RWS_CONFIG_CORS_ALLOW_METHODS,
56 boxed_cors_allow_methods.unwrap());
57 }
58
59 let boxed_cors_allow_headers = env::var(Config::RWS_CONFIG_CORS_ALLOW_HEADERS);
60 if boxed_cors_allow_headers.is_ok() {
61 println!(" Environment variable '{}' set to value '{}'",
62 Config::RWS_CONFIG_CORS_ALLOW_HEADERS,
63 boxed_cors_allow_headers.unwrap());
64 }
65
66 let boxed_cors_allow_credentials = env::var(Config::RWS_CONFIG_CORS_ALLOW_CREDENTIALS);
67 if boxed_cors_allow_credentials.is_ok() {
68 println!(" Environment variable '{}' set to value '{}'",
69 Config::RWS_CONFIG_CORS_ALLOW_CREDENTIALS,
70 boxed_cors_allow_credentials.unwrap());
71 }
72
73 let boxed_cors_expose_headers = env::var(Config::RWS_CONFIG_CORS_EXPOSE_HEADERS);
74 if boxed_cors_expose_headers.is_ok() {
75 println!(" Environment variable '{}' set to value '{}'",
76 Config::RWS_CONFIG_CORS_EXPOSE_HEADERS,
77 boxed_cors_expose_headers.unwrap());
78 }
79
80 let boxed_cors_max_age = env::var(Config::RWS_CONFIG_CORS_MAX_AGE);
81 if boxed_cors_max_age.is_ok() {
82 println!(" Environment variable '{}' set to value '{}'",
83 Config::RWS_CONFIG_CORS_MAX_AGE,
84 boxed_cors_max_age.unwrap());
85 }
86
87 println!(" End of System Environment Variables Section");
88}