webx_spa/lib.rs
1//! SPA static file serving middleware (package `rust-webx-spa`, imported as
2//! `webx_spa`).
3//!
4//! Serves files from a disk directory, from a table compiled into the binary,
5//! or both (disk wins), with history fallback to `index.html`. Embedded files
6//! are streamed with `ETag`, `Range`, and `HEAD` support.
7
8mod embed;
9mod spa;
10
11pub use embed::{ContentEncoding, EmbeddedAsset, EmbeddedAssets};
12pub use spa::{SpaMiddleware, SpaSource, EMBED_ENV};
13
14/// Re-exported so build-script-generated code can register a table without
15/// depending on `inventory` directly.
16pub use inventory;
17
18/// Include the asset table generated by `webx::builder()` in `build.rs`.
19///
20/// Prefer `#[webx::main(embed)]` in application code. This bang-macro is
21/// the low-level include used by that attribute (and by
22/// `#[webx::embed_assets]` in integration tests).
23///
24/// ```ignore
25/// // Usually you do not call this directly:
26/// webx::spa::embed_assets!();
27/// ```
28#[macro_export]
29macro_rules! embed_assets {
30 () => {
31 include!(concat!(env!("OUT_DIR"), "/webx_embedded_assets.rs"));
32 };
33}