use std::time::Duration;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AuthConfig {
pub secret: String,
pub public_paths: Vec<String>,
}
impl AuthConfig {
pub fn is_public(&self, path: &str) -> bool {
self.public_paths.iter().any(|item| item == path)
}
}
#[derive(Debug, Clone)]
pub struct RestConfig {
pub name: String,
pub timeout: Duration,
pub max_body_bytes: usize,
pub auth: Option<AuthConfig>,
}
impl Default for RestConfig {
fn default() -> Self {
Self {
name: "rs-zero".to_string(),
timeout: Duration::from_secs(5),
max_body_bytes: 1024 * 1024,
auth: None,
}
}
}