Skip to main content

Crate fetchlet_http

Crate fetchlet_http 

Source
Expand description

Serve shared fetchlet applications over HTTP.

FetchletService is a Tower service over http 1 types and is always available. The hyper, axum and actix features add thin integrations for those servers; with axum, Server serves one build behind Rust routes in a few lines. Artifact reads the output of fetchlet/build, and AssetService serves its client assets from an AssetArchive. WebviewResponder answers a webview’s custom URI scheme, such as Tauri’s, in-process with any of these services. The dev-reload feature adds DevReload, which serves an artifact while a build tool rewrites it, and the vite-dev feature adds ViteDev, which runs the server module from a Vite dev server through Vite’s module runner. The JavaScript engine is chosen on the fetchlet crate, and the transports of JavaScript’s outbound sockets and WebSockets are in fetchlet-net.

Macros§

include_artifact
Embed the artifact in $directory in the binary: its fetchlet.json, server.js and assets.flpk, which fetchlet/build writes with archiveArtifactAssets. $directory is a string literal or a macro such as concat! or env! that expands to one, and is resolved as include_bytes! resolves paths, relative to the file that calls it.

Structs§

ActixService
An actix-web handler for a shared fetchlet application.
Artifact
A build output of fetchlet/build: fetchlet.json, the server module and the client assets.
Asset
One served path of an AssetArchive.
AssetArchive
Client assets packed by writeAssetArchive in fetchlet/build.
AssetService
A Tower service that answers GET and HEAD from an AssetArchive and passes every other request to fallback.
AxumService
FetchletService with axum’s request and response types.
DevBody
The response body of a DevService: the generation’s body, that body followed by the reload script, or the reload poll’s answer.
DevReload
Serves an artifact while it is rebuilt, for development.
DevReloadBuilder
Settings for DevReload.
DevService
The Tower service of a DevReload.
FetchletService
A cloneable Tower service for a shared fetchlet application.
Generation
What one build of the artifact serves: a service and the applications it uses, which are shut down when a later build replaces them.
HyperConnection
HyperService for one connection, recording its peer address.
HyperService
FetchletService as a hyper 1 service.
PeerAddr
The peer address of the connection a request arrived on.
PublicOrigin
The configured public scheme and authority of incoming requests.
Reloads
Reports each new generation of a DevReload, for hosts that reload their views themselves.
RequestContext
Default metadata passed as the Fetch entry’s second argument.
Server
An axum server for one fetchlet/build artifact: Rust routes first, then the artifact’s client assets, then the application.
ViteDev
A connection to a Vite dev server running fetchlet/vite, for development without a build.
ViteProxy
The Tower service of ViteDev::proxy.
Webview
A Server started for a webview’s custom URI scheme: answers its requests and holds the application. Clones share it.
WebviewResponder
Answers a webview’s custom-protocol requests in-process with an HTTP service, such as an axum Router or a FetchletService.
WebviewScheme
A custom URI scheme a webview loads the application from, such as one registered with Tauri’s register_asynchronous_uri_scheme_protocol.

Enums§

ArtifactError
A failure to read an artifact.
AssetArchiveError
A failure to read an asset archive.
AssetFuture
The future of an AssetService call.
Error
Conversion and execution failures available to the Rust error callback.
ReloadError
A failure while loading a new build. The previous generation keeps serving.
ServerError
A failure to start serving.
ViteDevError
A failure to reach the Vite dev server or to read what it served.

Constants§

RELOAD_POLL_PATH
The path the reload script polls for a new generation.
RELOAD_SCRIPT_PATH
The path of the reload script that HTML pages link to.
VITE_BINDING
The binding name through which the development artifact reaches the Vite dev server; fetchlet/vite/dev-runner reads the same name.
VITE_URL_VARIABLE
The environment variable that names a Vite dev server to run from, read when the vite-dev feature is enabled.

Functions§

artifact_router
A router that serves the artifact’s client assets and passes every other request to the application.
connect_info
The client address recorded by into_make_service_with_connect_info.
peer_addr
The client address recorded by HyperService::connection.
router_transport
Serve host fetches with an axum Router.
service_transport
Serve host fetches with a Tower service, such as an axum Router.

Type Aliases§

AssetBody
The body of an AssetService response: an asset, or the fallback’s body.
BoxError
ViteBody
The response body of a ViteProxy: Vite’s or the app’s.