start implementing the periphery client

This commit is contained in:
beckerinj
2022-11-06 22:50:01 -05:00
parent fd13240134
commit 841b458f05
14 changed files with 2813 additions and 2708 deletions
+2 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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");
}