#serve #embed #axum #file

serve_embed

serve embedded file with axum

1 unstable release

0.1.0 Jul 15, 2023

#60 in #serve

MIT license

24KB
423 lines

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.

Dependencies

~8–18MB
~224K SLoC