Derive Macro actix_web_lab_derive::FromRequest
source · #[derive(FromRequest)]
{
// Attributes available to this derive:
#[from_request]
}
Expand description
Derive a FromRequest
implementation for an aggregate struct extractor.
All fields of the struct need to implement FromRequest
unless they are marked with annotations
that declare different handling is required.
§Examples
use actix_web::{Responder, http, get, web};
use actix_web_lab::FromRequest;
#[derive(Debug, FromRequest)]
struct RequestParts {
// the FromRequest impl is used for these fields
method: http::Method,
pool: web::Data<u32>,
req_body: String,
// equivalent to `req.app_data::<u64>().copied()`
#[from_request(copy_from_app_data)]
int: u64,
}
#[get("/")]
async fn handler(parts: RequestParts) -> impl Responder {
// ...
}