This commit is contained in:
Luca P 2022-02-12 18:51:42 +00:00
parent fd8f5e712f
commit e081f6736e
2 changed files with 9 additions and 9 deletions

View File

@ -18,7 +18,7 @@ use crate::{dev::Payload, Error, HttpRequest};
/// 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`].
///
/// 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.
///
/// # Configuration

View File

@ -24,7 +24,7 @@ use crate::{
guard::{Guard, GuardContext},
info::ConnectionInfo,
rmap::ResourceMap,
Error, HttpRequest, HttpResponse, FromRequest
Error, FromRequest, HttpRequest, HttpResponse,
};
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.
///
/// `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.
///
///
/// # Example
///
///
/// ```rust
/// use actix_web::dev::{ServiceRequest, ServiceResponse};
/// use actix_web::web::Path;
/// use actix_web::Error;
///
///
/// fn f(service_request: ServiceRequest) -> Result<ServiceResponse, Error> {
/// let path: Path<(String, u32)> = service_request.extract()?;
/// // [...]
@ -114,8 +114,8 @@ impl ServiceRequest {
/// }
/// ```
pub fn extract<T>(&mut self) -> <T as FromRequest>::Future
where
T: FromRequest
where
T: FromRequest,
{
T::from_request(&self.req, &mut self.payload)
}