Skip to main content

claims

Attribute Macro claims 

Source
#[claims]
Expand description

Marks a request struct as carrying authentication claims.

Appends a #[serde(skip)] pub claims: Option<Box<dyn IClaims>> field to the struct and generates an inherent set_claims method that shadows the blanket no-op IClaimsCarrier::set_claims. The dispatcher injects claims into the request before calling IRequestHandler::handle.

Must be the outermost attribute so that #[derive(...)] sees the injected field:

#[claims]
#[derive(Default, Deserialize)]
pub struct CreateCommentRequest {
    pub blog_id: i32,
    pub content: String,
}