Add /embedz handler to see what files are in binary.
This commit is contained in:
parent
737b290cc0
commit
bd3aac5bc0
14
src/web.rs
14
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<impl warp::Reply, warp::Rejection> {
|
||||
let mut w = Vec::new();
|
||||
write!(w, "<html>").unwrap();
|
||||
for path in Asset::iter() {
|
||||
write!(w, r#"<div><a href="{0}">{0}</a></div>"#, path).unwrap();
|
||||
}
|
||||
Ok(warp::http::Response::builder()
|
||||
.header("Content-Type", "text/html")
|
||||
.body(w))
|
||||
}
|
||||
|
||||
pub fn run(addr: SocketAddr, lib: Library) -> Result<(), Box<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user