From 95fa70d19eff42017b367464760988054dc20d54 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 16 Oct 2017 10:20:16 -0700 Subject: [PATCH] rename params to match_info --- src/application.rs | 3 ++- src/httprequest.rs | 4 ++-- src/router.rs | 2 +- tests/test_httprequest.rs | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/application.rs b/src/application.rs index c6fbfc5fe..819ab2aeb 100644 --- a/src/application.rs +++ b/src/application.rs @@ -294,7 +294,8 @@ impl Handler for InnerApplication { 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) { diff --git a/src/httprequest.rs b/src/httprequest.rs index 803171de4..fe5f7215d 100644 --- a/src/httprequest.rs +++ b/src/httprequest.rs @@ -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, diff --git a/src/router.rs b/src/router.rs index 94392a536..d9f21668b 100644 --- a/src/router.rs +++ b/src/router.rs @@ -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) { diff --git a/tests/test_httprequest.rs b/tests/test_httprequest.rs index 1cd1c3bb5..f2276ebab 100644 --- a/tests/test_httprequest.rs +++ b/tests/test_httprequest.rs @@ -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")); }