29 lines
1.1 KiB
Rust
29 lines
1.1 KiB
Rust
use crate::config::WebConfig;
|
|
use axum::extract::Extension;
|
|
use axum::response::{IntoResponse, Response};
|
|
|
|
pub async fn get_opensearch_xml(Extension(web_config): Extension<WebConfig>) -> impl IntoResponse {
|
|
let public_base = &web_config.web.public_base;
|
|
let formatted = format!(
|
|
r#"
|
|
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
|
|
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
|
|
<ShortName>QuickPeep</ShortName>
|
|
<Description>small-scale web search engine</Description>
|
|
<InputEncoding>UTF-8</InputEncoding>
|
|
<Image width="16" height="16" type="image/x-icon">{public_base}/favicon.ico</Image>
|
|
<Url type="text/html" template="{public_base}/search?q=%s"/>
|
|
</OpenSearchDescription>
|
|
"#
|
|
);
|
|
|
|
// Extras for the future:
|
|
// <Url type="application/x-suggestions+json" template="[suggestionURL]"/>
|
|
// <moz:SearchForm>[https://example.com/search]</moz:SearchForm>
|
|
|
|
Response::builder()
|
|
.header("content-type", "application/opensearchdescription+xml")
|
|
.body(formatted.into_response())
|
|
.unwrap()
|
|
}
|