tower-embed

Crates.iotower-embed
lib.rstower-embed
version0.2.0
created_at2026-01-22 23:55:15.13419+00
updated_at2026-01-23 10:28:19.316854+00
descriptionTower service to serve embedded assets
homepagehttps://github.com/mattiapenati/tower-embed
repositoryhttps://github.com/mattiapenati/tower-embed
max_upload_size
id2062986
size44,594
Mattia Penati (mattiapenati)

documentation

https://docs.rs/tower-embed

README

tower-embed

Latest Version Latest Version Apache 2.0 OR MIT licensed

This crate provides a tower service designed to provide embedded static assets support for web application. This service includes the following HTTP features:

  • Support for GET and HEAD requests
  • Content-Type header generation based on file MIME types
  • ETag header generation and validation
  • Last-Modified header generation and validation

Example

use axum::Router;
use tower_embed::rust_embed::RustEmbed;

#[derive(RustEmbed)]
#[folder = "assets"]
#[crate_path = "tower_embed::rust_embed"]
struct Assets;

#[tokio::main]
async fn main() {
    let assets = tower_embed::ServeEmbed::<Assets>::new();
    let router = Router::new().fallback_service(assets);

    let listener = tokio::net::TcpListener::bind("127.0.0.1:8080")
        .await
        .unwrap();
    axum::serve::serve(listener, router).await.unwrap();
}

License

Licensed under either of Apache License 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 11

cargo fmt