diff options
| author | Xe Iaso <me@christine.website> | 2022-06-08 17:20:48 -0400 |
|---|---|---|
| committer | Xe Iaso <me@christine.website> | 2022-06-08 17:20:48 -0400 |
| commit | aca8b8089264b911afa71b2334c8652002e003ac (patch) | |
| tree | 3f110e913ecf1d0e0b0a12a7f23e9f47fe359ff6 /src | |
| parent | dc3f6471e774eaafab92dfcd73dd089707646469 (diff) | |
| download | xesite-aca8b8089264b911afa71b2334c8652002e003ac.tar.xz xesite-aca8b8089264b911afa71b2334c8652002e003ac.zip | |
talks: add static analysis talk
Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'src')
| -rw-r--r-- | src/handlers/talks.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/handlers/talks.rs b/src/handlers/talks.rs index 22ee3cf..3b33431 100644 --- a/src/handlers/talks.rs +++ b/src/handlers/talks.rs @@ -4,6 +4,7 @@ use axum::{ extract::{Extension, Path}, response::Html, }; +use http::header::HeaderMap; use lazy_static::lazy_static; use prometheus::{opts, register_int_counter_vec, IntCounterVec}; use std::sync::Arc; @@ -25,10 +26,11 @@ pub async fn index(Extension(state): Extension<Arc<State>>) -> Result { Ok(Html(result)) } -#[instrument(skip(state))] +#[instrument(skip(state, headers))] pub async fn post_view( Path(name): Path<String>, Extension(state): Extension<Arc<State>>, + headers: HeaderMap, ) -> Result { let mut want: Option<Post> = None; @@ -38,6 +40,13 @@ pub async fn post_view( } } + let referer = if let Some(referer) = headers.get(http::header::REFERER) { + let referer = referer.to_str()?.to_string(); + Some(referer) + } else { + None + }; + match want { None => Err(PostNotFound(name).into()), Some(post) => { @@ -46,7 +55,7 @@ pub async fn post_view( .inc(); let body = templates::Html(post.body_html.clone()); let mut result: Vec<u8> = vec![]; - templates::talkpost_html(&mut result, post, body)?; + templates::talkpost_html(&mut result, post, body, referer)?; Ok(Html(result)) } } |
