mirror of
https://github.com/moghtech/komodo.git
synced 2026-10-29 08:04:54 +00:00
start implementing the periphery client
This commit is contained in:
@@ -33,7 +33,8 @@ pub struct JwtClient {
|
||||
|
||||
impl JwtClient {
|
||||
pub fn extension(config: &CoreConfig) -> JwtExtension {
|
||||
let key = Hmac::new_from_slice(config.jwt_secret.as_bytes()).unwrap();
|
||||
let key = Hmac::new_from_slice(config.jwt_secret.as_bytes())
|
||||
.expect("failed at taking HmacSha256 of jwt secret");
|
||||
let client = JwtClient {
|
||||
key,
|
||||
valid_for_ms: get_timelength_in_ms(config.jwt_valid_for),
|
||||
|
||||
+13
-2
@@ -11,8 +11,19 @@ use dotenv::dotenv;
|
||||
use mungos::{Deserialize, Mungos};
|
||||
use types::CoreConfig;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct Env {
|
||||
#[serde(default = "default_config_path")]
|
||||
pub config_path: String,
|
||||
}
|
||||
|
||||
pub fn load() -> CoreConfig {
|
||||
let config_path = env::var("CONFIG_PATH").unwrap_or("./config.json".to_string());
|
||||
let file = File::open(config_path).expect("failed to open config file");
|
||||
dotenv().ok();
|
||||
let env: Env = envy::from_env().expect("failed to parse environment variables");
|
||||
let file = File::open(&env.config_path).expect("failed to open config file");
|
||||
serde_json::from_reader(file).unwrap()
|
||||
}
|
||||
|
||||
pub fn default_config_path() -> String {
|
||||
"./config.json".to_string()
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,5 +28,5 @@ async fn main() {
|
||||
axum::Server::bind(&get_socket_addr(&config))
|
||||
.serve(app.into_make_service())
|
||||
.await
|
||||
.expect("server crashed");
|
||||
.expect("monitor core axum server crashed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user