#[request_cookie]Expand description
Extracts a specific cookie value or all cookies into a variable.
This attribute macro supports two syntaxes:
cookie(key => variable_name)- Extract a specific cookie value by keycookie(variable_name)- Extract all cookies as a raw string
ยงUsage
use hyperlane::*;
use hyperlane_macros::*;
#[request_cookie("session_id" => session_cookie_opt)]
async fn handle_with_session(ctx: Context) {
if let Some(session) = session_cookie_opt {
// Use the session cookie value
}
}For specific cookie extraction, the variable will be available as Option<String>.
For all cookies extraction, the variable will be available as String.