diff --git a/src/web.rs b/src/web.rs index 385e922..139f5d6 100644 --- a/src/web.rs +++ b/src/web.rs @@ -1,4 +1,5 @@ use std::error::Error; +use std::io::Write; use std::net::SocketAddr; use log::warn; @@ -100,12 +101,24 @@ fn image( #[folder = "react-slideshow/build/"] struct Asset; +fn embedz() -> Result { + let mut w = Vec::new(); + write!(w, "").unwrap(); + for path in Asset::iter() { + write!(w, r#"
{0}
"#, path).unwrap(); + } + Ok(warp::http::Response::builder() + .header("Content-Type", "text/html") + .body(w)) +} + pub fn run(addr: SocketAddr, lib: Library) -> Result<(), Box> { let lib = warp::any().map(move || lib.clone()); let index = warp::get2().and(warp::path::full()).and_then(index); let albums = warp::path("albums").and(lib.clone()).and_then(albums); + let embedz = warp::path("embedz").and_then(embedz); let album = warp::path("album") .and(lib.clone()) @@ -120,6 +133,7 @@ pub fn run(addr: SocketAddr, lib: Library) -> Result<(), Box> { let api = albums.or(album).or(image); let api = warp::path("api").and(api); + let api = api.or(embedz); // Fallback, always keep this last. let api = api.or(index);