mirror of
https://github.com/redlib-org/redlib.git
synced 2025-04-02 04:37:35 +03:00
fix: opensearch.xml route
This commit is contained in:
parent
357e7c2e09
commit
526c0d0797
2 changed files with 15 additions and 3 deletions
12
src/main.rs
12
src/main.rs
|
@ -64,6 +64,17 @@ async fn font() -> Result<Response<Body>, String> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn opensearch() -> Result<Response<Body>, 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<Response<Body>, String> {
|
async fn resource(body: &str, content_type: &str, cache: bool) -> Result<Response<Body>, String> {
|
||||||
let mut res = Response::builder()
|
let mut res = Response::builder()
|
||||||
.status(200)
|
.status(200)
|
||||||
|
@ -234,6 +245,7 @@ async fn main() {
|
||||||
app.at("/Inter.var.woff2").get(|_| font().boxed());
|
app.at("/Inter.var.woff2").get(|_| font().boxed());
|
||||||
app.at("/touch-icon-iphone.png").get(|_| iphone_logo().boxed());
|
app.at("/touch-icon-iphone.png").get(|_| iphone_logo().boxed());
|
||||||
app.at("/apple-touch-icon.png").get(|_| iphone_logo().boxed());
|
app.at("/apple-touch-icon.png").get(|_| iphone_logo().boxed());
|
||||||
|
app.at("/opensearch.xml").get(|_| opensearch().boxed());
|
||||||
app
|
app
|
||||||
.at("/playHLSVideo.js")
|
.at("/playHLSVideo.js")
|
||||||
.get(|_| resource(include_str!("../static/playHLSVideo.js"), "text/javascript", false).boxed());
|
.get(|_| resource(include_str!("../static/playHLSVideo.js"), "text/javascript", false).boxed());
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
<ShortName>Search Redlib</ShortName>
|
<ShortName>Search Redlib</ShortName>
|
||||||
<Description>Search for whatever you want on Redlib, awesome Reddit frontend</Description>
|
<Description>Search for whatever you want on Redlib, awesome Reddit frontend</Description>
|
||||||
<InputEncoding>UTF-8</InputEncoding>
|
<InputEncoding>UTF-8</InputEncoding>
|
||||||
<Image width="32" height="32" type="image/x-icon">/favicon.ico</Image>
|
<Image width="32" height="32" type="image/x-icon">https://localhost:8080/favicon.ico</Image>
|
||||||
<Url type="text/html" template="/search">
|
<Url type="text/html" template="https://localhost:8080/search">
|
||||||
<Param name="q" value="{searchTerms}"/>
|
<Param name="q" value="{searchTerms}"/>
|
||||||
</Url>
|
</Url>
|
||||||
<moz:SearchForm>/search</moz:SearchForm>
|
<moz:SearchForm>https://localhost:8080/search</moz:SearchForm>
|
||||||
</OpenSearchDescription>
|
</OpenSearchDescription>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue