diff options
| author | Christine Dodrill <me@christine.website> | 2020-07-26 23:12:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-26 23:12:01 -0400 |
| commit | 6438d334cb195af23967f28f55e7bd207e1938db (patch) | |
| tree | d293518b394aabcdc071fb83aeab81d31c642cef /src/handlers | |
| parent | f9e20750dc743dfb79268fc5e7c6baa1c774030a (diff) | |
| download | xesite-6438d334cb195af23967f28f55e7bd207e1938db.tar.xz xesite-6438d334cb195af23967f28f55e7bd207e1938db.zip | |
fix atom/RSS feeds (#186)
* fix atom feeds
* also fix RSS feeds
* add feeds fixed/flight journal post
* fix tests
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/feeds.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/handlers/feeds.rs b/src/handlers/feeds.rs index 7d7db32..752b08c 100644 --- a/src/handlers/feeds.rs +++ b/src/handlers/feeds.rs @@ -1,7 +1,7 @@ -use crate::app::State; +use crate::{app::State, templates}; use lazy_static::lazy_static; use prometheus::{opts, register_int_counter_vec, IntCounterVec}; -use std::sync::Arc; +use std::{sync::Arc, io}; use warp::{http::Response, Rejection, Reply}; lazy_static! { @@ -20,9 +20,8 @@ pub async fn jsonfeed(state: Arc<State>) -> Result<impl Reply, Rejection> { #[derive(Debug)] pub enum RenderError { - WriteAtom(atom_syndication::Error), - WriteRss(rss::Error), Build(warp::http::Error), + IO(io::Error), } impl warp::reject::Reject for RenderError {} @@ -31,10 +30,8 @@ pub async fn atom(state: Arc<State>) -> Result<impl Reply, Rejection> { HIT_COUNTER.with_label_values(&["atom"]).inc(); let state = state.clone(); let mut buf = Vec::new(); - state - .af - .write_to(&mut buf) - .map_err(RenderError::WriteAtom) + templates::blog_atom_xml(&mut buf, state.everything.clone()) + .map_err(RenderError::IO) .map_err(warp::reject::custom)?; Response::builder() .status(200) @@ -48,10 +45,8 @@ pub async fn rss(state: Arc<State>) -> Result<impl Reply, Rejection> { HIT_COUNTER.with_label_values(&["rss"]).inc(); let state = state.clone(); let mut buf = Vec::new(); - state - .rf - .write_to(&mut buf) - .map_err(RenderError::WriteRss) + templates::blog_rss_xml(&mut buf, state.everything.clone()) + .map_err(RenderError::IO) .map_err(warp::reject::custom)?; Response::builder() .status(200) |
