Migrate to actix

This commit is contained in:
2022-03-30 10:14:39 +02:00
parent d75242d213
commit 70df96f286
7 changed files with 613 additions and 1392 deletions

View File

@ -1,11 +1,20 @@
use std::path::{Path, PathBuf};
use rocket::serde::Deserialize;
use clap::Parser;
use crate::constants::USERS_LIST_FILE;
#[derive(Debug, Deserialize)]
#[serde(crate = "rocket::serde")]
/// Basic OIDC provider
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
pub struct AppConfig {
storage_path: PathBuf,
/// Listen address
#[clap(short, long, env, default_value = "0.0.0.0:8000")]
pub listen_address: String,
/// Storage path
#[clap(short, long, env)]
pub storage_path: String,
}
impl AppConfig {
@ -14,6 +23,6 @@ impl AppConfig {
}
pub fn users_file(&self) -> PathBuf {
self.storage_path.join(USERS_LIST_FILE)
self.storage_path().join(USERS_LIST_FILE)
}
}

View File

@ -7,7 +7,7 @@ pub struct EntityManager<E> {
list: Vec<E>,
}
impl<E> EntityManager<E> where E: rocket::serde::Serialize + rocket::serde::DeserializeOwned + Eq + Clone {
impl<E> EntityManager<E> where E: serde::Serialize + serde::de::DeserializeOwned + Eq + Clone {
/// Open entity
pub fn open_or_create<A: AsRef<Path>>(path: A) -> Res<Self> {
if !path.as_ref().is_file() {