A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1use actix_web::{
2 web::{self},
3 HttpResponse, Responder,
4};
5use mime_guess::from_path;
6use rust_embed::RustEmbed;
7
8#[derive(RustEmbed)]
9#[folder = "rockbox/dist/"]
10struct Asset;
11
12fn handle_embedded_file(path: &str) -> HttpResponse {
13 match Asset::get(path) {
14 Some(content) => HttpResponse::Ok()
15 .content_type(from_path(path).first_or_octet_stream().as_ref())
16 .body(content.data.into_owned()),
17 None => HttpResponse::NotFound().body("404 Not Found"),
18 }
19}
20
21#[actix_web::get("/")]
22pub async fn index() -> impl Responder {
23 handle_embedded_file("index.html")
24}
25
26pub async fn index_spa() -> impl Responder {
27 handle_embedded_file("index.html")
28}
29
30#[actix_web::get("/{_:.*}")]
31pub async fn dist(path: web::Path<String>) -> impl Responder {
32 handle_embedded_file(path.as_str())
33}