diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index a73ba2456..9d136b121 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -6,8 +6,11 @@ ### Changed - Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency. +### Added +- Add `ServiceRequest::{parts, request}()` getter methods. [#2786] [#2784]: https://github.com/actix/actix-web/pull/2784 +[#2786]: https://github.com/actix/actix-web/pull/2786 ## 4.1.0 - 2022-06-11 diff --git a/actix-web/src/service.rs b/actix-web/src/service.rs index a9e809bf9..0ad92d8a1 100644 --- a/actix-web/src/service.rs +++ b/actix-web/src/service.rs @@ -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