action

Attribute Macro action 

Source
#[action]
Expand description

Marks a function as an action (side effects, external APIs).

Actions can call external APIs and perform side effects. NOT transactional.

§Attributes

  • require_auth - Require authentication
  • require_role("admin") - Require specific role
  • timeout = 60 - Timeout in seconds

§Example

#[forge::action(timeout = 60)]
pub async fn sync_with_stripe(ctx: &ActionContext, user_id: Uuid) -> Result<SyncResult> {
    let customer = ctx.http().get("https://api.stripe.com/...").await?;
    // ...
}