nicer code
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m31s
CI/CD Pipeline / deploy (push) Successful in 1m50s

This commit is contained in:
Philipp Hofer
2025-10-13 10:02:46 +02:00
parent 30cd6d2c97
commit 8420104c68

View File

@@ -16,36 +16,21 @@ pub async fn stream_handler(State(state): State<Arc<AppState>>) -> impl IntoResp
fn feed(urls: &Vec<String>) -> String { fn feed(urls: &Vec<String>) -> String {
let mut ret = String::new(); let mut ret = String::new();
ret.push_str(r#"<?xml version="1.0" encoding="UTF-8"?>"#); ret.push_str(r#"<?xml version="1.0" encoding="UTF-8"?>"#);
ret.push('\n');
ret.push_str(r#"<rss version="2.0">"#); ret.push_str(r#"<rss version="2.0">"#);
ret.push('\n');
ret.push_str("<channel>"); ret.push_str("<channel>");
ret.push('\n');
ret.push_str("<title>Ö1 Morgenjournal Feed</title>"); ret.push_str("<title>Ö1 Morgenjournal Feed</title>");
ret.push('\n');
ret.push_str("<link>https://news.hofer.link</link>"); ret.push_str("<link>https://news.hofer.link</link>");
ret.push('\n');
ret.push_str("<description>Feed für Ö1 Morgenjournal. Live.</description>"); ret.push_str("<description>Feed für Ö1 Morgenjournal. Live.</description>");
ret.push('\n');
for url in urls { for url in urls {
ret.push_str("<item>"); ret.push_str("<item>");
ret.push('\n'); ret.push_str(&format!("<title>Morgenjournal</title>"));
ret.push_str(&format!(" <title>Morgenjournal DATE</title>")); ret.push_str(&format!("<link>{}</link>", quick_xml::escape::escape(url)));
ret.push('\n'); ret.push_str(&format!("<description>Morgenjournal</description>"));
ret.push_str(&format!(
" <link>{}</link>",
quick_xml::escape::escape(url)
));
ret.push('\n');
ret.push_str(&format!(" <description>my desc</description>"));
ret.push('\n');
ret.push_str("</item>"); ret.push_str("</item>");
ret.push('\n');
} }
ret.push_str(" </channel>"); ret.push_str(" </channel>");
ret.push('\n');
ret.push_str("</rss>"); ret.push_str("</rss>");
ret ret