| Crates.io | axum-embeddy |
| lib.rs | axum-embeddy |
| version | 0.1.0 |
| created_at | 2025-10-14 19:04:04.77833+00 |
| updated_at | 2025-10-14 19:04:04.77833+00 |
| description | Serve embedded files with axum |
| homepage | https://codeberg.org/kujeger/axum-embeddy |
| repository | https://codeberg.org/kujeger/axum-embeddy |
| max_upload_size | |
| id | 1882917 |
| size | 2,362,277 |
axum-embeddy is a fork of axum-embed, in order to have a release that supports newer axum versions.
axum-embeddy is a library that provides a service for serving embedded files using the axum web framework.
This library uses the rust_embed crate to embedded files into the binary at compile time, and the axum crate to serve these files over HTTP.
use rust_embed::RustEmbed;
use axum_embeddy::ServeEmbed;
use tokio::net::TcpListener;
#[derive(RustEmbed, Clone)]
#[folder = "examples/assets/"]
struct Assets;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let listener = TcpListener::bind("127.0.0.1:8080").await?;
let serve_assets = ServeEmbed::<Assets>::new();
let app = axum::Router::new().nest_service("/", serve_assets);
axum::serve(listener, app).await?;
Ok(())
}
Please see the examples directory for a working example.
The axum_embeddy library has the capability to serve compressed files, given that the client supports it and the compressed file is available.
The compression methods supported include br (Brotli), gzip, and deflate.
If the client supports multiple compression methods, axum_embeddy will select the first one listed in the Accept-Encoding header. Please note that the weight of encoding is not considered in this ction.
In the absence of client support for any compression methods, axum_embeddy will serve the file in its uncompressed form.
If a file with the extension .br (for Brotli), .gz (for GZip), or .zz (for Deflate) is available, axum_embeddy will serve the file in its compressed form.
An uncompressed file is must be available for the compressed file to be served.