|
|
|
|
@ -54,8 +54,12 @@ impl Globals<'_> {
@@ -54,8 +54,12 @@ impl Globals<'_> {
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let jwt_decoding_key = |
|
|
|
|
config.get_str("jwt_secret").map(|secret| jsonwebtoken::DecodingKey::from_secret(secret.as_bytes()).into_static()).ok(); |
|
|
|
|
let jwt_decoding_key = config |
|
|
|
|
.get_str("jwt_secret") |
|
|
|
|
.map(ToString::to_string) |
|
|
|
|
.or(std::env::var("JWT_SECRET")) |
|
|
|
|
.map(|secret| jsonwebtoken::DecodingKey::from_secret(secret.as_bytes()).into_static()) |
|
|
|
|
.ok(); |
|
|
|
|
|
|
|
|
|
Ok(Self { |
|
|
|
|
globals, |
|
|
|
|
@ -63,7 +67,7 @@ impl Globals<'_> {
@@ -63,7 +67,7 @@ impl Globals<'_> {
|
|
|
|
|
reqwest_client: reqwest::Client::new(), |
|
|
|
|
server_name: config |
|
|
|
|
.get_str("server_name") |
|
|
|
|
.map(std::string::ToString::to_string) |
|
|
|
|
.map(ToString::to_string) |
|
|
|
|
.unwrap_or_else(|_| { |
|
|
|
|
std::env::var("SERVER_NAME").unwrap_or_else(|_| "localhost".to_string()) |
|
|
|
|
}) |
|
|
|
|
|