diff --git a/src/main.rs b/src/main.rs index bcfcd51..e1b010d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,17 @@ async fn font() -> Result, String> { ) } +async fn opensearch() -> Result, String> { + Ok( + Response::builder() + .status(200) + .header("content-type", "application/opensearchdescription+xml") + .header("Cache-Control", "public, max-age=1209600, s-maxage=86400") + .body(include_bytes!("../static/opensearch.xml").as_ref().into()) + .unwrap_or_default(), + ) +} + async fn resource(body: &str, content_type: &str, cache: bool) -> Result, String> { let mut res = Response::builder() .status(200) @@ -234,6 +245,7 @@ async fn main() { app.at("/Inter.var.woff2").get(|_| font().boxed()); app.at("/touch-icon-iphone.png").get(|_| iphone_logo().boxed()); app.at("/apple-touch-icon.png").get(|_| iphone_logo().boxed()); + app.at("/opensearch.xml").get(|_| opensearch().boxed()); app .at("/playHLSVideo.js") .get(|_| resource(include_str!("../static/playHLSVideo.js"), "text/javascript", false).boxed()); diff --git a/static/opensearch.xml b/static/opensearch.xml index 4bbef00..5864ef7 100644 --- a/static/opensearch.xml +++ b/static/opensearch.xml @@ -3,9 +3,9 @@ Search Redlib Search for whatever you want on Redlib, awesome Reddit frontend UTF-8 - /favicon.ico - + https://localhost:8080/favicon.ico + - /search + https://localhost:8080/search