aboutsummaryrefslogtreecommitdiff
path: root/lib/jsonfeed/src/feed.rs
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2021-01-14 22:36:34 -0500
committerGitHub <noreply@github.com>2021-01-14 22:36:34 -0500
commitd2455aa1c1bfc599a07966a7d717c1380d41bbc0 (patch)
treec2b206aa41cd6f0e13d61b5455861f09ab5d1304 /lib/jsonfeed/src/feed.rs
parenta359f54a91f4aeb914c69f59a02afabccd72450e (diff)
downloadxesite-d2455aa1c1bfc599a07966a7d717c1380d41bbc0.tar.xz
xesite-d2455aa1c1bfc599a07966a7d717c1380d41bbc0.zip
Cache better (#296)
* Many improvements around bandwidth use - Use ETags for RSS/Atom feeds - Use cache-control headers - Update to rust nightly (for rust-analyzer and faster builds) - Limit feeds to the last 20 posts: https://twitter.com/theprincessxena/status/1349891678857998339 - Use if-none-match to limit bandwidth further Also does this: - bump go_vanity to 0.3.0 and lets users customize the branch name - fix formatting on jsonfeed - remove last vestige of kubernetes/docker support Signed-off-by: Christine Dodrill <me@christine.website> * expire cache quicker for dynamic pages Signed-off-by: Christine Dodrill <me@christine.website> * add rss ttl Signed-off-by: Christine Dodrill <me@christine.website> * add blogpost Signed-off-by: Christine Dodrill <me@christine.website>
Diffstat (limited to 'lib/jsonfeed/src/feed.rs')
-rw-r--r--lib/jsonfeed/src/feed.rs36
1 files changed, 13 insertions, 23 deletions
diff --git a/lib/jsonfeed/src/feed.rs b/lib/jsonfeed/src/feed.rs
index 8b5b5ce..320feb6 100644
--- a/lib/jsonfeed/src/feed.rs
+++ b/lib/jsonfeed/src/feed.rs
@@ -1,7 +1,7 @@
use std::default::Default;
-use item::Item;
use builder::Builder;
+use item::Item;
const VERSION_1: &'static str = "https://jsonfeed.org/version/1";
@@ -145,9 +145,9 @@ pub struct Hub {
#[cfg(test)]
mod tests {
+ use super::*;
use serde_json;
use std::default::Default;
- use super::*;
#[test]
fn serialize_feed() {
@@ -168,18 +168,16 @@ mod tests {
#[test]
fn deserialize_feed() {
- let json = r#"{"version":"https://jsonfeed.org/version/1","title":"some title","items":[]}"#;
+ let json =
+ r#"{"version":"https://jsonfeed.org/version/1","title":"some title","items":[]}"#;
let feed: Feed = serde_json::from_str(&json).unwrap();
let expected = Feed {
version: "https://jsonfeed.org/version/1".to_string(),
- title: "some title".to_string(),
- items: vec![],
- ..Default::default()
+ title: "some title".to_string(),
+ items: vec![],
+ ..Default::default()
};
- assert_eq!(
- feed,
- expected
- );
+ assert_eq!(feed, expected);
}
#[test]
@@ -208,10 +206,7 @@ mod tests {
size_in_bytes: Some(1),
duration_in_seconds: Some(1),
};
- assert_eq!(
- attachment,
- expected
- );
+ assert_eq!(attachment, expected);
}
#[test]
@@ -229,17 +224,15 @@ mod tests {
#[test]
fn deserialize_author() {
- let json = r#"{"name":"bob jones","url":"http://example.com","avatar":"http://img.com/blah"}"#;
+ let json =
+ r#"{"name":"bob jones","url":"http://example.com","avatar":"http://img.com/blah"}"#;
let author: Author = serde_json::from_str(&json).unwrap();
let expected = Author {
name: Some("bob jones".to_string()),
url: Some("http://example.com".to_string()),
avatar: Some("http://img.com/blah".to_string()),
};
- assert_eq!(
- author,
- expected
- );
+ assert_eq!(author, expected);
}
#[test]
@@ -262,10 +255,7 @@ mod tests {
type_: "some-type".to_string(),
url: "http://example.com".to_string(),
};
- assert_eq!(
- hub,
- expected
- );
+ assert_eq!(hub, expected);
}
#[test]