use crate::app::config::Configuration;
use crate::app::state::ApplicationState;
use rocket::Build;
use rocket::Rocket;

pub fn init(config: &Configuration) -> super::InfallibleResult<ApplicationState> {
    Ok(Some(ApplicationState {
        assets_dir: config.assets_dir.clone(),
        base_uri: config.base_uri.clone(),
        base_uri_onion: config.base_uri_onion().to_owned(),
    }))
}

pub fn register(
    rocket: Rocket<Build>,
    _config: &Configuration,
    state: ApplicationState,
) -> Rocket<Build> {
    rocket.manage(state)
}
