diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index e3ac9eb..afd1347 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,8 +5,11 @@ use std::collections::BTreeMap; use std::fs::File; use std::sync::Arc; -use lfm_embed::{CONFIG, ResponseCtx}; +use lfm_embed::CONFIG; +use lfm_embed::ctx::get_ctx; +use lfm_embed::cache::user::get_userinfo; use lfm_embed::cache::font::FontQuery; +use lfm_embed::theming::render_theme; use log::LevelFilter; use dotenv::var; @@ -45,12 +48,12 @@ async fn main() { let user = warp::path!("user" / String) .and(warp::query::<UserQuery>()) .then(|s, q: UserQuery| async move { - log::debug!(target: "lfm_embed::server::user", "Handling request for user `{s}` with {q:?}"); - let (ctx, dur) = lfm_embed::cache::user::get_userinfo(&s).await; - let ResponseCtx(data, status) = ResponseCtx::create(ctx, q.font, q.rest).await; + log::debug!(target: "lfm_embed::main::user", "Handling request for user `{s}` with {q:?}"); + let (userinfo, refresh) = get_userinfo(&s).await; + let (ctx, status) = get_ctx(userinfo, q.font, q.rest).await; - let (theme, res) = lfm_embed::theming::render_theme(q.theme.as_deref(), &data); - log::debug!(target: "lfm_embed::server::user", "Using theme {theme}"); + let (theme, res) = render_theme(q.theme.as_deref(), &ctx); + log::debug!(target: "lfm_embed::main::user", "Using theme {theme}"); match res { Err(status) => @@ -63,7 +66,7 @@ async fn main() { Ok(contents) => http::Response::builder() .status(status) - .header("Refresh", dur.as_secs()) + .header("Refresh", refresh.as_secs()) .header("X-Selected-Theme", theme) .header("Content-Type", "text/html") .body(contents) |