mirror of https://github.com/fafhrd91/actix-web
Fmt
This commit is contained in:
parent
fd8f5e712f
commit
e081f6736e
|
@ -18,7 +18,7 @@ use crate::{dev::Payload, Error, HttpRequest};
|
||||||
/// A type that implements [`FromRequest`] is called an **extractor** and can extract data from
|
/// A type that implements [`FromRequest`] is called an **extractor** and can extract data from
|
||||||
/// the request. Some types that implement this trait are: [`Json`], [`Header`], and [`Path`].
|
/// the request. Some types that implement this trait are: [`Json`], [`Header`], and [`Path`].
|
||||||
///
|
///
|
||||||
/// Check out [`ServiceRequest::extract`](crate::dev::ServiceRequest::extract) if you want to leverage
|
/// Check out [`ServiceRequest::extract`](crate::dev::ServiceRequest::extract) if you want to leverage
|
||||||
/// extractors when implementing middlewares.
|
/// extractors when implementing middlewares.
|
||||||
///
|
///
|
||||||
/// # Configuration
|
/// # Configuration
|
||||||
|
|
|
@ -24,7 +24,7 @@ use crate::{
|
||||||
guard::{Guard, GuardContext},
|
guard::{Guard, GuardContext},
|
||||||
info::ConnectionInfo,
|
info::ConnectionInfo,
|
||||||
rmap::ResourceMap,
|
rmap::ResourceMap,
|
||||||
Error, HttpRequest, HttpResponse, FromRequest
|
Error, FromRequest, HttpRequest, HttpResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) type BoxedHttpService = BoxService<ServiceRequest, ServiceResponse<BoxBody>, Error>;
|
pub(crate) type BoxedHttpService = BoxService<ServiceRequest, ServiceResponse<BoxBody>, Error>;
|
||||||
|
@ -96,17 +96,17 @@ impl ServiceRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use an [extractor](crate::FromRequest) to build a type out of the incoming request.
|
/// Use an [extractor](crate::FromRequest) to build a type out of the incoming request.
|
||||||
///
|
///
|
||||||
/// `extract` is particularly handy when you need to use an extractor inside
|
/// `extract` is particularly handy when you need to use an extractor inside
|
||||||
/// a middleware implementation.
|
/// a middleware implementation.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_web::dev::{ServiceRequest, ServiceResponse};
|
/// use actix_web::dev::{ServiceRequest, ServiceResponse};
|
||||||
/// use actix_web::web::Path;
|
/// use actix_web::web::Path;
|
||||||
/// use actix_web::Error;
|
/// use actix_web::Error;
|
||||||
///
|
///
|
||||||
/// fn f(service_request: ServiceRequest) -> Result<ServiceResponse, Error> {
|
/// fn f(service_request: ServiceRequest) -> Result<ServiceResponse, Error> {
|
||||||
/// let path: Path<(String, u32)> = service_request.extract()?;
|
/// let path: Path<(String, u32)> = service_request.extract()?;
|
||||||
/// // [...]
|
/// // [...]
|
||||||
|
@ -114,8 +114,8 @@ impl ServiceRequest {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn extract<T>(&mut self) -> <T as FromRequest>::Future
|
pub fn extract<T>(&mut self) -> <T as FromRequest>::Future
|
||||||
where
|
where
|
||||||
T: FromRequest
|
T: FromRequest,
|
||||||
{
|
{
|
||||||
T::from_request(&self.req, &mut self.payload)
|
T::from_request(&self.req, &mut self.payload)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue