Expand description
sppl — embed static Svelte (and other static) apps into Rust servers.
ⓘ
#[derive(sppl::RustEmbed)]
#[folder = "$CARGO_MANIFEST_DIR/../app/build"]
#[crate_path = "sppl::rust_embed"]
struct App;
#[tokio::main]
async fn main() {
let app = sppl::axum::router::<App>();
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}§Compression
sppl understands a directory in which compressible files have been
pre-gzipped (e.g. index.html → index.html.gz). Use
build::gzip_assets from your build.rs to do it once at compile time;
at request time sppl::resolve prefers the .gz variant if present.
By default the axum router sends the stored gzipped bytes to every
client with Content-Encoding: gzip, regardless of Accept-Encoding.
Modern clients decompress transparently and you cap the per-request CPU
cost at zero. Flip axum::RouterConfig::never_decompress to false
to restore on-the-fly decompression via flate2 for clients that
truly can’t accept gzip.
Modules§
Structs§
- Asset
- A resolved embedded asset, after applying SvelteKit
adapter-staticand SPA-fallback lookup rules and after picking a.gzvariant if available. - Embedded
File - A file embedded into the binary
Traits§
- Rust
Embed - A directory of binary assets.
Functions§
- resolve
- Look up a file in an embedded asset bundle, applying the resolution rules
that match SvelteKit’s
adapter-staticoutput, with a.gzfast-path: