added parts and request methods, updated changelog

This commit is contained in:
erhodes 2022-06-17 11:30:41 -06:00
parent 062127a210
commit 0428c01181
2 changed files with 13 additions and 1 deletions

View File

@ -1,7 +1,7 @@
# Changelog # Changelog
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
- Add `ServiceRequest::{parts, request}()` to make it easier to use middlewares that only have access to a `&ServiceRequest`.
## 4.1.0 - 2022-06-11 ## 4.1.0 - 2022-06-11
### Added ### Added

View File

@ -95,6 +95,18 @@ impl ServiceRequest {
(&mut self.req, &mut self.payload) (&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). /// 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 /// Returns the `T` extractor's `Future` type which can be `await`ed. This is particularly handy