crate
weft_api
Server-side API routes for Weft apps, written once with actix-web and run either way:
- On Vercel, each
api/<name>.rsis a Rust function:weft_api::vercel::run(my_app::server::configure).await(featurevercel, built onvercel_runtime's actix support). - In Docker (or locally), one process serves the built site and the same routes:
weft_api::serve("dist", 8080, my_app::server::configure)(featureserve).
Ready-made routes: mongo (feature mongodb), halaxy (feature halaxy), and relay for sources browsers may not read. send makes weft_data requests from the server (feature client, on by default).
Modules
- key_proxy
A route in front of an API that needs a key, so a component's
srccan reach it without the key going anywhere near the browser. - relay
The relay for sources the browser isn't allowed to read: a
srcorloadon a site that sends no CORS header. The page asks/api/weft-relay?url=…, and this route fetches the URL and answers with what the site sent. Seeweft_data::relay.
Structs
Functions
env
pub fn env(name: &str) -> Result<String, HttpResponse>An environment variable, or a 500 naming the missing setting (never its value).
load_dotenv
pub fn load_dotenv(path: impl AsRef<Path>) -> usizeLoad KEY=value lines from a .env file into the environment, without overriding variables that are already set (so the host's settings win). Returns how many were loaded.
parse_dotenv
pub fn parse_dotenv(text: &str) -> Vec<(String, String)>Parse .env text: KEY=value, optional export , quotes, # comments.
Re-exports
- weft_data
pub use actix_web;