Skip to content

Commit

Permalink
Add getters for &ServiceRequest (#2786)
Browse files Browse the repository at this point in the history
  • Loading branch information
junbl committed Jun 22, 2022
1 parent 6b71962 commit 5d0e813
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions actix-web/CHANGES.md
Expand Up @@ -2,7 +2,10 @@

## Unreleased - 2022-xx-xx
- Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency.
### Added
- Add `ServiceRequest::{parts, request}()` getter methods. [#2786]

[#2786]: https://github.com/actix/actix-web/pull/2786

## 4.1.0 - 2022-06-11
### Added
Expand Down
12 changes: 12 additions & 0 deletions actix-web/src/service.rs
Expand Up @@ -95,6 +95,18 @@ impl ServiceRequest {
(&mut self.req, &mut self.payload)
}

/// Returns immutable accessors to inner parts.
#[inline]
pub fn parts(&self) -> (&HttpRequest, &Payload) {
(&self.req, &self.payload)
}

/// Returns immutable accessor to inner [`HttpRequest`].
#[inline]
pub fn request(&self) -> &HttpRequest {
&self.req
}

/// Derives a type from this request using an [extractor](crate::FromRequest).
///
/// Returns the `T` extractor's `Future` type which can be `await`ed. This is particularly handy
Expand Down

0 comments on commit 5d0e813

Please sign in to comment.