This commit is contained in:
Mateusz Gruszczyński
2026-09-02 08:50:51 +02:00
parent a161d8785d
commit 9c6e51fc35
52 changed files with 3763 additions and 285 deletions
+12
View File
@@ -69,6 +69,18 @@ async fn language_file(Path(file): Path<String>) -> Response {
response.headers_mut().insert(header::CONTENT_TYPE, HeaderValue::from_static("text/plain; charset=utf-8"));
response
}
async fn preset_index() -> Response {
static_response(PRESET_MANIFEST_JSON, "application/json; charset=utf-8", "no-cache")
}
async fn preset_file(Path(file): Path<String>) -> Response {
if let Some((_, body)) = PRESET_ASSETS.iter().find(|(filename, _)| *filename == file) {
return static_response(*body, "application/json; charset=utf-8", "no-cache");
}
let mut response = Response::new(Body::from("Preset not found"));
*response.status_mut() = StatusCode::NOT_FOUND;
response.headers_mut().insert(header::CONTENT_TYPE, HeaderValue::from_static("text/plain; charset=utf-8"));
response
}
fn static_response(body: &'static str, content_type: &'static str, cache: &'static str) -> Response {
let mut response = Response::new(Body::from(body));
response.headers_mut().insert(header::CONTENT_TYPE, HeaderValue::from_static(content_type));