mirror of https://github.com/fafhrd91/actix-web
tweak docs
This commit is contained in:
parent
7c3985288a
commit
95cff76f5e
|
@ -1,7 +1,10 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
- Add `ServiceRequest::extract` to make it easier to use extractors when writing middlewares.
|
- Add `ServiceRequest::extract` to make it easier to use extractors when writing middlewares. [#2647]
|
||||||
|
|
||||||
|
[#2647]: https://github.com/actix/actix-web/pull/2647
|
||||||
|
|
||||||
|
|
||||||
## 4.0.1 - 2022-02-25
|
## 4.0.1 - 2022-02-25
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -18,12 +18,11 @@ 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
|
||||||
/// extractors when implementing middlewares.
|
/// leverage extractors when implementing middlewares.
|
||||||
///
|
///
|
||||||
/// # Configuration
|
/// # Configuration
|
||||||
/// An extractor can be customized by injecting the corresponding configuration with one of:
|
/// An extractor can be customized by injecting the corresponding configuration with one of:
|
||||||
///
|
|
||||||
/// - [`App::app_data()`][crate::App::app_data]
|
/// - [`App::app_data()`][crate::App::app_data]
|
||||||
/// - [`Scope::app_data()`][crate::Scope::app_data]
|
/// - [`Scope::app_data()`][crate::Scope::app_data]
|
||||||
/// - [`Resource::app_data()`][crate::Resource::app_data]
|
/// - [`Resource::app_data()`][crate::Resource::app_data]
|
||||||
|
|
|
@ -95,20 +95,20 @@ impl ServiceRequest {
|
||||||
(&mut self.req, &mut self.payload)
|
(&mut self.req, &mut self.payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use an [extractor](crate::FromRequest) to build a type out of the incoming request.
|
/// Derives a type from this request using an [extractor](crate::FromRequest).
|
||||||
///
|
///
|
||||||
/// `extract` is particularly handy when you need to use an extractor inside
|
/// Returns the `T` extractor's `Future` type which can be `await`ed. This is particularly handy
|
||||||
/// a middleware implementation.
|
/// when you want to use an extractor in a middleware implementation.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Examples
|
||||||
|
/// ```
|
||||||
|
/// use actix_web::{
|
||||||
|
/// dev::{ServiceRequest, ServiceResponse},
|
||||||
|
/// web::Path, Error
|
||||||
|
/// };
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// async fn my_helper(mut srv_req: ServiceRequest) -> Result<ServiceResponse, Error> {
|
||||||
/// use actix_web::dev::{ServiceRequest, ServiceResponse};
|
/// let path = srv_req.extract::<Path<(String, u32)>>().await?;
|
||||||
/// use actix_web::web::Path;
|
|
||||||
/// use actix_web::Error;
|
|
||||||
///
|
|
||||||
/// async fn f(mut service_request: ServiceRequest) -> Result<ServiceResponse, Error> {
|
|
||||||
/// let path = service_request.extract::<Path<(String, u32)>>().await?;
|
|
||||||
/// // [...]
|
/// // [...]
|
||||||
/// # todo!()
|
/// # todo!()
|
||||||
/// }
|
/// }
|
||||||
|
|
Loading…
Reference in New Issue