#[derive(PlexusRequest)]
{
// Attributes available to this derive:
#[from_cookie]
#[from_header]
#[from_query]
#[from_peer]
#[from_auth_context]
}
Expand description
Derive macro for typed HTTP/WebSocket request extraction.
Generates impl PlexusRequest (extraction) and impl schemars::JsonSchema
(with x-plexus-source extensions) for the annotated struct.
§Field annotations
#[from_cookie("name")]— extract from named cookie#[from_header("name")]— extract from named HTTP header#[from_query("name")]— extract from named URI query parameter#[from_peer]— copyctx.peer(peer socket address)#[from_auth_context]— copyctx.auth(auth context)- (no annotation) —
Default::default()
§Example
ⓘ
use plexus_macros::PlexusRequest;
#[derive(PlexusRequest)]
struct MyRequest {
#[from_cookie("access_token")]
auth_token: String,
#[from_header("origin")]
origin: Option<String>,
#[from_peer]
peer_addr: Option<std::net::SocketAddr>,
}