File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,12 +5,28 @@ use serde::de::DeserializeOwned;
55
66use crate :: { extractors:: AsyncFromRequestMut , types:: Request } ;
77
8+ /// Represents a form extracted from an HTTP request body.
9+ ///
10+ /// This generic struct wraps the deserialized form data of type `T`.
811pub struct Form < T > ( pub T ) ;
912
13+ /// Implementation of the `AsyncFromRequestMut` trait for extracting form data from an HTTP request.
14+ ///
15+ /// This implementation supports asynchronous extraction of form data from requests with the
16+ /// `application/x-www-form-urlencoded` content type. The extracted data is deserialized into
17+ /// the generic type `T`.
1018impl < ' a , T > AsyncFromRequestMut < ' a > for Form < T >
1119where
1220 T : DeserializeOwned + Send ,
1321{
22+ /// Extracts form data from the HTTP request body.
23+ ///
24+ /// # Arguments
25+ /// * `req` - A mutable reference to the HTTP request from which the form data is extracted.
26+ ///
27+ /// # Returns
28+ /// * `Ok(Form<T>)` - If the request contains valid form data that can be deserialized into type `T`.
29+ /// * `Err` - If the content type is invalid or the form data cannot be parsed or deserialized.
1430 async fn from_request ( req : & ' a mut Request ) -> anyhow:: Result < Self > {
1531 if req
1632 . headers ( )
You can’t perform that action at this time.
0 commit comments