mod builder;
mod config;
use crate::runtimes::http::HttpRuntime;
use std::path::Path;
use sword_core::Config;
pub use builder::ApplicationBuilder;
pub use config::ApplicationConfig;
pub struct Application {
http_runtime: HttpRuntime,
pub config: Config,
}
impl Application {
pub(crate) fn new(http_runtime: HttpRuntime, config: Config) -> Self {
Self {
http_runtime,
config,
}
}
pub fn builder() -> ApplicationBuilder {
ApplicationBuilder::new()
}
pub fn from_config_path<P: AsRef<Path>>(path: P) -> ApplicationBuilder {
ApplicationBuilder::from_config(
Config::from_path(path).expect("Configuration loading error"),
)
}
pub async fn run(&self) {
self.http_runtime.start().await;
}
pub fn router(&self) -> axum::Router {
self.http_runtime.router()
}
}