mirror of
https://github.com/actix/actix-web.git
synced 2024-12-18 14:16:47 +00:00
rename params to match_info
This commit is contained in:
parent
02033724d8
commit
95fa70d19e
4 changed files with 8 additions and 7 deletions
|
@ -294,7 +294,8 @@ impl<S: 'static> Handler for InnerApplication<S> {
|
|||
|
||||
fn handle(&self, req: HttpRequest, payload: Payload) -> Task {
|
||||
if let Ok(h) = self.router.recognize(req.path()) {
|
||||
h.handler.handle(req.with_params(h.params), payload, Rc::clone(&self.state))
|
||||
h.handler.handle(
|
||||
req.with_match_info(h.params), payload, Rc::clone(&self.state))
|
||||
} else {
|
||||
for (prefix, handler) in &self.handlers {
|
||||
if req.path().starts_with(prefix) {
|
||||
|
|
|
@ -119,10 +119,10 @@ impl HttpRequest {
|
|||
/// Route supports glob patterns: * for a single wildcard segment and :param
|
||||
/// for matching storing that segment of the request url in the Params object.
|
||||
#[inline]
|
||||
pub fn params(&self) -> &Params { &self.params }
|
||||
pub fn match_info(&self) -> &Params { &self.params }
|
||||
|
||||
/// Create new request with Params object.
|
||||
pub fn with_params(self, params: Params) -> Self {
|
||||
pub fn with_match_info(self, params: Params) -> Self {
|
||||
HttpRequest {
|
||||
method: self.method,
|
||||
uri: self.uri,
|
||||
|
|
|
@ -26,7 +26,7 @@ impl Router {
|
|||
pub(crate) fn call(&self, req: HttpRequest, payload: Payload) -> Task
|
||||
{
|
||||
if let Ok(h) = self.resources.recognize(req.path()) {
|
||||
h.handler.handle(req.with_params(h.params), payload, Rc::new(()))
|
||||
h.handler.handle(req.with_match_info(h.params), payload, Rc::new(()))
|
||||
} else {
|
||||
for (prefix, app) in &self.apps {
|
||||
if req.path().starts_with(prefix) {
|
||||
|
|
|
@ -77,13 +77,13 @@ fn test_request_query() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_request_params() {
|
||||
fn test_request_match_info() {
|
||||
let req = HttpRequest::new(Method::GET, Uri::try_from("/?id=test").unwrap(),
|
||||
Version::HTTP_11, HeaderMap::new());
|
||||
|
||||
let mut params = Params::new();
|
||||
params.insert("key".to_owned(), "value".to_owned());
|
||||
|
||||
let req = req.with_params(params);
|
||||
assert_eq!(req.params().find("key"), Some("value"));
|
||||
let req = req.with_match_info(params);
|
||||
assert_eq!(req.match_info().find("key"), Some("value"));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue