Skip to main content

fetchlet_http/
lib.rs

1//! Serve shared fetchlet applications over HTTP.
2//!
3//! [`FetchletService`] is a Tower service over `http` 1 types and is always
4//! available. The `hyper`, `axum` and `actix` features add thin integrations
5//! for those servers; with `axum`, `Server` serves one build behind Rust
6//! routes in a few lines. [`Artifact`] reads the output of `fetchlet/build`, and
7//! [`AssetService`] serves its client assets from an [`AssetArchive`].
8//! [`WebviewResponder`] answers a webview's custom URI scheme, such as
9//! Tauri's, in-process with any of these services.
10//! The `dev-reload` feature adds `DevReload`, which serves an artifact while a
11//! build tool rewrites it, and the `vite-dev` feature adds `ViteDev`, which
12//! runs the server module from a Vite dev server through Vite's module runner.
13//! The JavaScript engine is chosen on the `fetchlet` crate, and the
14//! transports of JavaScript's outbound sockets and WebSockets are in
15//! `fetchlet-net`.
16
17mod artifact;
18mod assets;
19mod service;
20mod webview;
21
22#[cfg(feature = "actix")]
23mod actix_server;
24#[cfg(feature = "axum")]
25mod axum_server;
26#[cfg(feature = "dev-reload")]
27mod dev;
28#[cfg(feature = "hyper")]
29mod hyper_server;
30#[cfg(feature = "vite-dev")]
31mod vite_dev;
32
33pub use artifact::{Artifact, ArtifactError};
34pub use assets::{Asset, AssetArchive, AssetArchiveError, AssetBody, AssetFuture, AssetService};
35pub use service::{
36    BoxError, Error, FetchletService, PublicOrigin, RequestContext, service_transport,
37};
38pub use webview::{WebviewResponder, WebviewScheme};
39
40#[cfg(feature = "actix")]
41pub use actix_server::ActixService;
42#[cfg(feature = "axum")]
43pub use axum_server::{AxumService, artifact_router, connect_info, router_transport};
44#[cfg(all(feature = "axum", fetchlet_engine))]
45pub use axum_server::{Server, ServerError, VITE_URL_VARIABLE, Webview};
46#[cfg(feature = "dev-reload")]
47pub use dev::{
48    DevBody, DevReload, DevReloadBuilder, DevService, Generation, RELOAD_POLL_PATH,
49    RELOAD_SCRIPT_PATH, ReloadError, Reloads,
50};
51#[cfg(feature = "hyper")]
52pub use hyper_server::{HyperConnection, HyperService, PeerAddr, peer_addr};
53#[cfg(feature = "vite-dev")]
54pub use vite_dev::{VITE_BINDING, ViteBody, ViteDev, ViteDevError, ViteProxy};
55
56#[doc(hidden)]
57pub mod __private {
58    pub use bytes::Bytes;
59}