Crate axum_embed_files

Crate axum_embed_files 

Source
Expand description

Serve static embedded files.

This crate provides utilities to serve static files that are embedded in the Rust binary at compile time. This is most useful for including small asset files directly in a web server. The files are served with Content-Type, ETag, and Last-Modified headers, and conditional requests are handled correctly (well, just If-None-Match so far).

For development, you may wish to serve the files directly from the local file system. Compile with the feature serve-from-fs and get coding!

§Example

use axum::Router;
use axum_embed_files::embed_files;

fn router<S: Clone + Sync + Send + 'static>() -> Router<S> {
    embed_files!("assets", [
        "img/logo.svg",
        "style.css",
    ])
}

Modules§

service

Macros§

embed_file
Embed a local file in a tower Service.
embed_files
Build an axum Router to serve embedded files.