1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-18 22:26:37 +00:00

rename params to match_info

This commit is contained in:
Nikolay Kim 2017-10-16 10:20:16 -07:00
parent 02033724d8
commit 95fa70d19e
4 changed files with 8 additions and 7 deletions

View file

@ -294,7 +294,8 @@ impl<S: 'static> Handler for InnerApplication<S> {
fn handle(&self, req: HttpRequest, payload: Payload) -> Task { fn handle(&self, req: HttpRequest, payload: Payload) -> Task {
if let Ok(h) = self.router.recognize(req.path()) { 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 { } else {
for (prefix, handler) in &self.handlers { for (prefix, handler) in &self.handlers {
if req.path().starts_with(prefix) { if req.path().starts_with(prefix) {

View file

@ -119,10 +119,10 @@ impl HttpRequest {
/// Route supports glob patterns: * for a single wildcard segment and :param /// Route supports glob patterns: * for a single wildcard segment and :param
/// for matching storing that segment of the request url in the Params object. /// for matching storing that segment of the request url in the Params object.
#[inline] #[inline]
pub fn params(&self) -> &Params { &self.params } pub fn match_info(&self) -> &Params { &self.params }
/// Create new request with Params object. /// Create new request with Params object.
pub fn with_params(self, params: Params) -> Self { pub fn with_match_info(self, params: Params) -> Self {
HttpRequest { HttpRequest {
method: self.method, method: self.method,
uri: self.uri, uri: self.uri,

View file

@ -26,7 +26,7 @@ impl Router {
pub(crate) fn call(&self, req: HttpRequest, payload: Payload) -> Task pub(crate) fn call(&self, req: HttpRequest, payload: Payload) -> Task
{ {
if let Ok(h) = self.resources.recognize(req.path()) { 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 { } else {
for (prefix, app) in &self.apps { for (prefix, app) in &self.apps {
if req.path().starts_with(prefix) { if req.path().starts_with(prefix) {

View file

@ -77,13 +77,13 @@ fn test_request_query() {
} }
#[test] #[test]
fn test_request_params() { fn test_request_match_info() {
let req = HttpRequest::new(Method::GET, Uri::try_from("/?id=test").unwrap(), let req = HttpRequest::new(Method::GET, Uri::try_from("/?id=test").unwrap(),
Version::HTTP_11, HeaderMap::new()); Version::HTTP_11, HeaderMap::new());
let mut params = Params::new(); let mut params = Params::new();
params.insert("key".to_owned(), "value".to_owned()); params.insert("key".to_owned(), "value".to_owned());
let req = req.with_params(params); let req = req.with_match_info(params);
assert_eq!(req.params().find("key"), Some("value")); assert_eq!(req.match_info().find("key"), Some("value"));
} }