Skip to content

Commit 526c0d0

Browse files
committed
fix: opensearch.xml route
1 parent 357e7c2 commit 526c0d0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ async fn font() -> Result<Response<Body>, String> {
6464
)
6565
}
6666

67+
async fn opensearch() -> Result<Response<Body>, String> {
68+
Ok(
69+
Response::builder()
70+
.status(200)
71+
.header("content-type", "application/opensearchdescription+xml")
72+
.header("Cache-Control", "public, max-age=1209600, s-maxage=86400")
73+
.body(include_bytes!("../static/opensearch.xml").as_ref().into())
74+
.unwrap_or_default(),
75+
)
76+
}
77+
6778
async fn resource(body: &str, content_type: &str, cache: bool) -> Result<Response<Body>, String> {
6879
let mut res = Response::builder()
6980
.status(200)
@@ -234,6 +245,7 @@ async fn main() {
234245
app.at("/Inter.var.woff2").get(|_| font().boxed());
235246
app.at("/touch-icon-iphone.png").get(|_| iphone_logo().boxed());
236247
app.at("/apple-touch-icon.png").get(|_| iphone_logo().boxed());
248+
app.at("/opensearch.xml").get(|_| opensearch().boxed());
237249
app
238250
.at("/playHLSVideo.js")
239251
.get(|_| resource(include_str!("../static/playHLSVideo.js"), "text/javascript", false).boxed());

static/opensearch.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<ShortName>Search Redlib</ShortName>
44
<Description>Search for whatever you want on Redlib, awesome Reddit frontend</Description>
55
<InputEncoding>UTF-8</InputEncoding>
6-
<Image width="32" height="32" type="image/x-icon">/favicon.ico</Image>
7-
<Url type="text/html" template="/search">
6+
<Image width="32" height="32" type="image/x-icon">https://localhost:8080/favicon.ico</Image>
7+
<Url type="text/html" template="https://localhost:8080/search">
88
<Param name="q" value="{searchTerms}"/>
99
</Url>
10-
<moz:SearchForm>/search</moz:SearchForm>
10+
<moz:SearchForm>https://localhost:8080/search</moz:SearchForm>
1111
</OpenSearchDescription>

0 commit comments

Comments
 (0)