serve_embed

Crates.ioserve_embed
lib.rsserve_embed
version0.1.0
sourcesrc
created_at2023-07-15 03:56:39.973146
updated_at2023-07-15 03:56:39.973146
descriptionserve embedded file with axum
homepage
repository
max_upload_size
id916961
size67,157
(CliffHan)

documentation

README

serve_embed

Serve embedded file with axum

#[derive(rust_embed::RustEmbed)]
#[folder = "target_folder"]
struct EmbedFiles;

let addr: std::net::SocketAddr = "127.0.0.1:8080".parse().unwrap();
let service = serve_embed::ServeEmbed::<EmbedFiles>::default().append_index_html_on_directories(true);
let app = axum::Router::new().fallback_service(service);
axum::Server::bind(&addr).serve(app.into_make_service()).await.unwrap();

Please check #example/hello.rs for the complete, working example.

Commit count: 0

cargo fmt