Move loading config outside of router setup
All checks were successful
Push Workflows / rustfmt (push) Successful in 5s
Push Workflows / tailwind-build (push) Successful in 6s
Push Workflows / clippy (push) Successful in 18s
Push Workflows / docs (push) Successful in 23s
Push Workflows / test (push) Successful in 26s
Push Workflows / build (push) Successful in 54s
Push Workflows / nix-build (push) Successful in 5m54s
All checks were successful
Push Workflows / rustfmt (push) Successful in 5s
Push Workflows / tailwind-build (push) Successful in 6s
Push Workflows / clippy (push) Successful in 18s
Push Workflows / docs (push) Successful in 23s
Push Workflows / test (push) Successful in 26s
Push Workflows / build (push) Successful in 54s
Push Workflows / nix-build (push) Successful in 5m54s
This commit is contained in:
@@ -5,7 +5,9 @@ use dioxus::{
|
||||
|
||||
use crate::App;
|
||||
use crate::server::{
|
||||
auth::build_auth_layer, config, database, key_val_store,
|
||||
auth::build_auth_layer,
|
||||
config::{self, Config},
|
||||
database, key_val_store,
|
||||
require_auth_mw::require_auth_middleware,
|
||||
};
|
||||
use crate::util::error::{Contextualize, Error, Result};
|
||||
@@ -15,17 +17,20 @@ pub fn main() -> Result<std::convert::Infallible> {
|
||||
tracing::warn!("Error reading .env: {e}");
|
||||
}
|
||||
|
||||
// `Ok(...?)` is because `dioxus::serve` expects an `anyhow::Result`
|
||||
dioxus::serve(async move || Ok(router_setup().await?));
|
||||
}
|
||||
|
||||
/// Set up the axum Router
|
||||
async fn router_setup() -> Result<Router> {
|
||||
tracing::debug!("Loading configuration...");
|
||||
let config = config::load_config()
|
||||
.map_err(|e| Error::message_here(e.to_string()))
|
||||
.err_context("Failed to load config")?;
|
||||
|
||||
// `Ok(...?)` is because `dioxus::serve` expects an `anyhow::Result`
|
||||
dioxus::serve(move || {
|
||||
let config = config.clone();
|
||||
async move { Ok(router_setup(config).await?) }
|
||||
});
|
||||
}
|
||||
|
||||
/// Set up the axum Router
|
||||
async fn router_setup(config: Config) -> Result<Router> {
|
||||
let db_pool = database::setup(config.database.connection_uri())
|
||||
.await
|
||||
.err_context("Failed database setup")?;
|
||||
|
||||
Reference in New Issue
Block a user