47 lines
1.2 KiB
Rust
47 lines
1.2 KiB
Rust
/**
|
|
* The main server entrypoint for Contaminate
|
|
*/
|
|
|
|
extern crate config;
|
|
extern crate pretty_env_logger;
|
|
|
|
use async_std::task;
|
|
use log::*;
|
|
|
|
/**
|
|
* Load the settings based on the hierarchy.
|
|
*
|
|
* First we load the configuration file (contaminate.yml) if it exists
|
|
* Then we look at environment variables.
|
|
*/
|
|
fn load_settings() -> config::Config {
|
|
let mut settings = config::Config::default();
|
|
settings.set_default("registry", "https://registry-1.docker.io")
|
|
.expect("Could not set the default for `registry`");
|
|
settings.set_default("layers_dir", "./layers.d")
|
|
.expect("Could not set the default for `layers_dir`");
|
|
|
|
settings
|
|
.merge(config::File::with_name("contaminate").required(false))
|
|
.expect("Failed to load settings in contaminate.ymll")
|
|
.merge(config::Environment::with_prefix("CT"))
|
|
.expect("Failed to load settings defined by CT_* env vars");
|
|
|
|
return settings;
|
|
}
|
|
|
|
fn main() -> Result<(), std::io::Error> {
|
|
pretty_env_logger::init();
|
|
|
|
task::block_on(async {
|
|
let mut app = tide::new();
|
|
app.at("/").get(|_| async move { "Hello, world!" });
|
|
app.listen("127.0.0.1:9000").await?;
|
|
Ok(())
|
|
})
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
}
|