Skip to content

module

effects

Requests for templates: load declarations and the request commands (get, post, put, patch, delete) in handlers.

weft-core only describes a request; whatever installs a requester sends it. weft_data does (in the browser, while prerendering and in tests), with the same loader, parsing and build-time baking as a chart's src. Without one, a load stays loading and a command does nothing.

Structs

  • Request

    A request a template describes.

Enums

  • Purpose

    Whether a request is a template's load or a handler's command.

Functions

clear_requester

pub fn clear_requester()

Remove the requester.

has_requester

pub fn has_requester() -> bool

Whether a requester is installed.

resolve

pub fn resolve(url: &str) -> String

url resolved against the app's base: data/x.json under /blog/ is /blog/data/x.json. Absolute paths and full URLs stay as they are.

send

pub fn send(req: Request, reply: Reply) -> bool

Send req. Returns false (and never calls reply) without a requester. reply may run before this returns, or later.

set_requester

pub fn set_requester(f: impl Fn(Request, Reply) + 'static)

Set how template requests are sent.

Type aliases

Reply

pub type Reply = Box<dyn FnOnce(Result<Value, String>)>;

Called once with the parsed answer, or a message.