Skip to content

Commit

Permalink
tweak docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Mar 28, 2022
1 parent 7c39852 commit 95cff76
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
5 changes: 4 additions & 1 deletion actix-web/CHANGES.md
@@ -1,7 +1,10 @@
# Changelog

## 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
### Fixed
Expand Down
5 changes: 2 additions & 3 deletions actix-web/src/extract.rs
Expand Up @@ -18,12 +18,11 @@ 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
/// extractors when implementing middlewares.
/// Check out [`ServiceRequest::extract`](crate::dev::ServiceRequest::extract) if you want to
/// leverage extractors when implementing middlewares.
///
/// # Configuration
/// An extractor can be customized by injecting the corresponding configuration with one of:
///
/// - [`App::app_data()`][crate::App::app_data]
/// - [`Scope::app_data()`][crate::Scope::app_data]
/// - [`Resource::app_data()`][crate::Resource::app_data]
Expand Down
22 changes: 11 additions & 11 deletions actix-web/src/service.rs
Expand Up @@ -95,20 +95,20 @@ impl ServiceRequest {
(&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
/// a middleware implementation.
/// Returns the `T` extractor's `Future` type which can be `await`ed. This is particularly handy
/// when you want to use an extractor in a middleware implementation.
///
/// # Example
///
/// ```rust
/// use actix_web::dev::{ServiceRequest, ServiceResponse};
/// use actix_web::web::Path;
/// use actix_web::Error;
/// # Examples
/// ```
/// use actix_web::{
/// dev::{ServiceRequest, ServiceResponse},
/// web::Path, Error
/// };
///
/// async fn f(mut service_request: ServiceRequest) -> Result<ServiceResponse, Error> {
/// let path = service_request.extract::<Path<(String, u32)>>().await?;
/// async fn my_helper(mut srv_req: ServiceRequest) -> Result<ServiceResponse, Error> {
/// let path = srv_req.extract::<Path<(String, u32)>>().await?;
/// // [...]
/// # todo!()
/// }
Expand Down

0 comments on commit 95cff76

Please sign in to comment.