Skip to main content

endpoint

Macro endpoint 

Source
endpoint!() { /* proc-macro */ }
Expand description

Defines an endpoint type with builder-style options.

Desugars nested wrappers (Protected, Validated, Strict, etc.) into a single readable declaration.

§Syntax

endpoint! {
    GET "users" / u32 => Json<User>,
    auth: AuthUser,
    errors: JsonError,
    strict: true,
}

endpoint! {
    POST "users",
    body: CreateUser => Json<User>,
    auth: AuthUser,
    validate: CreateUserValidator,
    content_type: json,
    errors: JsonError,
    version: V1,
}

§Fields

  • Method + path + => response (required)
  • body: request body type (for POST/PUT/PATCH)
  • auth: wraps in Protected<Auth, _>
  • validate: wraps in Validated<V, _>
  • content_type: wraps in ContentType<C, _> (json or a type)
  • errors: sets the Err type parameter
  • version: wraps in Versioned<V, _>
  • strict: wraps in Strict<_> (if true)
  • rate_limit: wraps in RateLimited<R, _>