Skip to main content

flux_verify_api/
config.rs

1use std::env;
2
3#[derive(Debug, Clone)]
4pub struct Config {
5    pub host: String,
6    pub port: u16,
7    pub plato_url: Option<String>,
8    pub plato_token: Option<String>,
9}
10
11impl Config {
12    pub fn from_env() -> Self {
13        Self {
14            host: env::var("VERIFY_HOST").unwrap_or_else(|_| "0.0.0.0".into()),
15            port: env::var("VERIFY_PORT")
16                .ok()
17                .and_then(|p| p.parse().ok())
18                .unwrap_or(8080),
19            plato_url: env::var("VERIFY_PLATO_URL").ok(),
20            plato_token: env::var("VERIFY_PLATO_TOKEN").ok(),
21        }
22    }
23
24    pub fn bind_addr(&self) -> String {
25        format!("{}:{}", self.host, self.port)
26    }
27}