#axum #static #file #serve


static file serving router for axum server

7 releases (4 stable)

1.2.1 Jan 22, 2023
1.1.0 Jan 22, 2023
0.1.2 Jan 22, 2023

#5 in #serve

35 downloads per month

MIT license

113 lines


GitHub license

static file serving router for axum server


  1. axum 0.6.*


Usage is very simple.

First install crate.

cargo add axum_static

Then, create a static route and nest it in the existing route like so

let app = Router::new()
        .route("/", get(index))
        .nest("/static", axum_static::static_router("static"))

The argument of the static_router function is the path to read static files based on the project root path.

Then you can read the file like this. It can also be a sub directory.

This is the end.

How easy is it?


~210K SLoC