Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getters for &ServiceRequest #2786

Merged
merged 4 commits into from Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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