embed_files

Macro embed_files 

Source
macro_rules! embed_files {
    (
        $dir:literal, [
        $(
            $file:literal
        ),* $(,)?
        ]
    ) => { ... };
}
Expand description

Build an axum Router to serve embedded files.

embed_files!(dir: &str, files: [&str]) -> axum::Router;

This macro creates an axum::Router that routes each file by the path specified. The files are loaded from the dir directory, relative to the CARGO_MANIFEST_PATH.

ยง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",
    ])
}