1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-11 09:49:29 +00:00

expose app's ResourceMap via resource_map method

This commit is contained in:
Nikolay Kim 2019-07-17 11:33:05 +06:00
parent c45728ac01
commit c65dbaf88e
3 changed files with 18 additions and 0 deletions

View file

@ -6,10 +6,14 @@
* Add `Responder` impl for `(T, StatusCode) where T: Responder`
* Allow to access app's resource map via
`ServiceRequest::resource_map()` and `HttpRequest::resource_map()` methods.
### Changed
* Upgrade `rand` dependency version to 0.7
## [1.0.3] - 2019-06-28
### Added

View file

@ -174,6 +174,12 @@ impl HttpRequest {
self.url_for(name, &NO_PARAMS)
}
#[inline]
/// Get a reference to a `ResourceMap` of current application.
pub fn resource_map(&self) -> &ResourceMap {
&self.0.rmap
}
/// Peer socket address
///
/// Peer address is actual socket address, if proxy is used in front of

View file

@ -18,6 +18,7 @@ use crate::dev::insert_slash;
use crate::guard::Guard;
use crate::info::ConnectionInfo;
use crate::request::HttpRequest;
use crate::rmap::ResourceMap;
pub trait HttpServiceFactory {
fn register(self, config: &mut AppService);
@ -169,10 +170,17 @@ impl ServiceRequest {
}
#[inline]
/// Get a mutable reference to the Path parameters.
pub fn match_info_mut(&mut self) -> &mut Path<Url> {
self.0.match_info_mut()
}
#[inline]
/// Get a reference to a `ResourceMap` of current application.
pub fn resource_map(&self) -> &ResourceMap {
self.0.resource_map()
}
/// Service configuration
#[inline]
pub fn app_config(&self) -> &AppConfig {