Skip to main content

Crate ferro_bundle

Crate ferro_bundle 

Source
Expand description

In-memory immutable byte blobs with content-hashed URLs and one-year immutable caching.

See the crate README for the bundle-vs-filesystem split: ferro-bundle handles compile-time-embedded immutable assets; the framework’s filesystem static-file handler at ferro::static_files handles mutable on-disk tenant assets.

§Usage

Register bundles at boot, then dispatch via the framework adapter (ferro::bundle::Bundle::serve) in a handler mounted on /bundles/{filename} and on each registered alias path.

use ferro_bundle::Bundle;

// Boot-time registration. Builder order matters: content_type BEFORE with_alias.
Bundle::new("embed-v1", include_bytes!("../assets/embed-v1.js"))
    .content_type("application/javascript")
    .with_alias("/embed/v1.js");

// Mount the framework adapter (in framework crate) on /bundles/* and alias paths.
// ferro::bundle::Bundle::serve(req) wraps serve_path into an HttpResponse.

§Builder order

Boot-time builder chain: Bundle::new(name, bytes).content_type(ct).with_alias(path). Call .content_type(...) before .with_alias(...).content_type re-keys the bundle’s URL (the extension is appended), and .with_alias captures the current hashed URL at the time it is called.

Structs§

Bundle
In-memory immutable byte blob registered at boot.
BundleResponse
Framework-agnostic result of dispatching a bundle request.

Enums§

Error
Single error type for the ferro-bundle crate.

Functions§

mime_from_ext
Map a file extension to its MIME type string.
serve_path
Dispatch a request to the bundle registry by path + optional If-None-Match.

Type Aliases§

Result
Convenience alias.