pub struct Action {
pub name: String,
pub method: Method,
pub path: String,
pub audience: Audience,
pub input: Option<Schema>,
pub outcome: Outcome,
pub captcha: bool,
}Expand description
One route the module serves, described for a renderer.
Fields§
§name: StringKebab-case, unique within the module (join, confirm,
export-csv).
method: MethodHTTP method, serialized as its upper-case name.
path: StringPath relative to /v1/<module>, always starting with /.
audience: Audience§input: Option<Schema>JSON Schema of the request body (or of the query for a GET).
None for an action that takes nothing.
outcome: Outcome§captcha: boolWhether the module verifies a captcha token on this action when the
Captcha port is configured; the renderer then includes the widget.
Implementations§
Source§impl Action
impl Action
Sourcepub fn post(name: impl Into<String>, path: impl Into<String>) -> Self
pub fn post(name: impl Into<String>, path: impl Into<String>) -> Self
A public POST that answers 202, the common case for a signup
form. Add .input::<Body>(), .captcha() and friends.
Sourcepub fn get(name: impl Into<String>, path: impl Into<String>) -> Self
pub fn get(name: impl Into<String>, path: impl Into<String>) -> Self
A GET. Audience defaults to Link because a module’s GETs are
the signed-link landings; call .audience(..) otherwise.
Sourcepub fn delete(name: impl Into<String>, path: impl Into<String>) -> Self
pub fn delete(name: impl Into<String>, path: impl Into<String>) -> Self
A DELETE, admin by default.
pub fn new( name: impl Into<String>, method: Method, path: impl Into<String>, ) -> Self
pub fn audience(self, audience: Audience) -> Self
Sourcepub fn input<T: JsonSchema>(self) -> Self
pub fn input<T: JsonSchema>(self) -> Self
Derives the input schema from the handler’s own body type.
Sourcepub fn input_schema(self, schema: Schema) -> Self
pub fn input_schema(self, schema: Schema) -> Self
Supplies a schema built by hand or adjusted after derivation (a
select whose options come from runtime settings).
pub fn outcome(self, outcome: Outcome) -> Self
Sourcepub fn accepted(self, message: impl Into<String>) -> Self
pub fn accepted(self, message: impl Into<String>) -> Self
Shorthand for .outcome(Outcome::Accepted { message }).