pub struct UrlEncodedBody<T>(pub T);
Expand description
Parse a URL-encoded request body, such as a web form.
§Guide
Check out the relevant section
of Pavex’s guide for a thorough introduction to UrlEncodedBody
.
§Example
use pavex::request::body::UrlEncodedBody;
// You must derive `serde::Deserialize` for the type you want to extract,
// in this case `HomeListing`.
#[derive(serde::Deserialize)]
pub struct HomeListing {
address: String,
price: u64,
}
// The `UrlEncodedBody` extractor deserializes the request body into
// the type you specified—`HomeListing` in this case.
pub fn get_home(body: &UrlEncodedBody<HomeListing>) -> String {
format!(
"The home you want to sell for {} is located at {}",
body.0.price,
body.0.address
)
}
Tuple Fields§
§0: T
Implementations§
source§impl<T> UrlEncodedBody<T>
impl<T> UrlEncodedBody<T>
pub fn extract<'head, 'body>(
request_head: &'head RequestHead,
buffered_body: &'body BufferedBody,
) -> Result<Self, ExtractUrlEncodedBodyError>where
T: Deserialize<'body>,
source§impl UrlEncodedBody<()>
impl UrlEncodedBody<()>
sourcepub fn register(bp: &mut Blueprint) -> RegisteredConstructor<'_>
pub fn register(bp: &mut Blueprint) -> RegisteredConstructor<'_>
Register the default constructor
for UrlEncodedBody
with a Blueprint
.
sourcepub fn default_constructor() -> Constructor
pub fn default_constructor() -> Constructor
The default constructor
and error handler for UrlEncodedBody
.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for UrlEncodedBody<T>where
T: Freeze,
impl<T> RefUnwindSafe for UrlEncodedBody<T>where
T: RefUnwindSafe,
impl<T> Send for UrlEncodedBody<T>where
T: Send,
impl<T> Sync for UrlEncodedBody<T>where
T: Sync,
impl<T> Unpin for UrlEncodedBody<T>where
T: Unpin,
impl<T> UnwindSafe for UrlEncodedBody<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more