diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index e2fea85..af00d3f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -219,16 +219,22 @@ async fn service<C: Controller>( .await .map(|resp| match resp { Response::Raw(resp) => resp, - Response::Page(page) => { + Response::Page(mut page) => { if !page.script_src.is_empty() { script_csp = page.script_src.join(" "); } if let Some(src) = page.frame_src { frame_csp = src; } + page.header.push_str( + &controller + .user_info_html(&parts) + .map(|h| format!("<div class=user-info>{}</div>", h)) + .unwrap_or_default(), + ); Builder::new() .content_type(mime::TEXT_HTML) - .body(render_page(&page, controller, &parts).into()) + .body(render_page(&page).into()) .unwrap() } }) @@ -266,7 +272,7 @@ pub struct Page { frame_src: Option<&'static str>, } -fn render_page<C: Controller>(page: &Page, controller: &C, parts: &Parts) -> String { +fn render_page(page: &Page) -> String { let mut out = String::new(); out.push_str("<!doctype html><html><head><meta charset=utf-8>"); out.push_str(&format!("<title>{}</title>", html_escape(&page.title))); @@ -274,12 +280,6 @@ fn render_page<C: Controller>(page: &Page, controller: &C, parts: &Parts) -> Str out.push_str(include_str!("static/style.css")); out.push_str("</style></head><body><header id=header>"); out.push_str(&page.header); - out.push_str( - &controller - .user_info_html(parts) - .map(|h| format!("<div class=user-info>{}</div>", h)) - .unwrap_or_default(), - ); out.push_str("</header>"); out.push_str(&page.body); for script in &page.scripts { |