Skip to main content

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
8pub mod assets;
9mod embed;
10mod spa;
11
12pub use embed::{ContentEncoding, EmbeddedAsset, EmbeddedAssets};
13pub use spa::{SpaMiddleware, SpaSource, EMBED_ENV};
14
15/// Re-exported so build-script-generated code can register a table without
16/// depending on `inventory` directly.
17pub use inventory;
18
19/// Include the asset table generated by `webx::builder()` in `build.rs`.
20///
21/// Prefer `#[webx::main(embed)]` in application code. This bang-macro is
22/// the low-level include used by that attribute (and by
23/// `#[webx::embed_assets]` in integration tests).
24///
25/// ```ignore
26/// // Usually you do not call this directly:
27/// webx::spa::embed_assets!();
28/// ```
29#[macro_export]
30macro_rules! embed_assets {
31    () => {
32        include!(concat!(env!("OUT_DIR"), "/webx_embedded_assets.rs"));
33    };
34}