pub fn bootstrap<'a, ConfigExt, S>(sources: S) -> Result<AppConfig<ConfigExt>>Expand description
Reads AppConfig and calls init_tracing.
Return Error if fails to read AppConfig or init_tracing returns error.
Return Error if called twice because of internal call to [tracing_subscriber::registry().try_init()].
use fregate::*;
use fregate::axum::{Router, routing::get, response::IntoResponse};
#[tokio::main]
async fn main() {
std::env::set_var("TEST_PORT", "3333");
std::env::set_var("TEST_NUMBER", "1010");
let config: AppConfig = bootstrap([
ConfigSource::File("./examples/configuration/app.yaml"),
ConfigSource::EnvPrefix("TEST"),
])
.unwrap();
Application::new(config)
.router(Router::new().route("/", get(|| async { "Hello World"})))
.serve()
.await
.unwrap();
}