/// Create rocket config from environment variables
Create rocket config from environment variables
Create rocket config from environment variables
pub fn from_env() -> Config {
    let environment = Environment::active().expect("No environment found");
    let port = env::var("PORT")
        .unwrap_or_else(|_| "8000".to_string())
        .parse::<u16>()
        .expect("PORT environment variable should parse to an integer");
    let mut database_config = HashMap::new();
    let mut databases = HashMap::new();
    let database_url =
        env::var("DATABASE_URL").expect("No DATABASE_URL environment variable found");
    database_config.insert("url", Value::from(database_url));
    databases.insert("diesel_postgres_pool", Value::from(database_config));
    let mut builder = Config::build(environment).environment(environment);
    if env::var("PROD").unwrap_or("false".to_string()) != "true" {
        builder = builder.address("127.0.0.1");
    }
    builder
        .port(port)
        .extra("databases", databases)
        .limits(
            Limits::new()
                .limit("forms", 3 * 1024 * 1024)
                .limit("json", 3 * 1024 * 1024),
        )
        .finalize()
        .unwrap()
}
pub fn from_env ( ) -> Config { let environment = Environment :: active ( ) . expect ( " " ) ; let port = env :: var ( " " ) . unwrap_or_else ( | _ | " " . to_string ( ) ) . parse :: < u16 > ( ) . expect ( " " ) ; let mut database_config = HashMap :: new ( ) ; let mut databases = HashMap :: new ( ) ; let database_url = env :: var ( " " ) . expect ( " " ) ; database_config . insert ( " " , Value :: from ( database_url ) ) ; databases . insert ( " " , Value :: from ( database_config ) ) ; let mut builder = Config :: build ( environment ) . environment ( environment ) ; if env :: var ( " " ) . unwrap_or ( " " . to_string ( ) ) != " " { builder = builder . address ( " " ) ; } builder . port ( port ) . extra ( " " , databases ) . limits ( Limits :: new ( ) . limit ( " " , 3 * 1024 * 1024 ) . limit ( " " , 3 * 1024 * 1024 ) , ) . finalize ( ) . unwrap ( ) }
Create rocket config from environment variables
Create rocket config from environment variables