1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

new router recognizer

This commit is contained in:
Nikolay Kim
2017-10-16 19:21:24 -07:00
parent 35107f64e7
commit f59f68eded
10 changed files with 229 additions and 42 deletions

View File

@ -79,14 +79,15 @@ fn test_request_query() {
#[test]
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("/value/?id=test").unwrap(),
Version::HTTP_11, HeaderMap::new());
let mut params = Params::new();
params.insert("key".to_owned(), "value".to_owned());
let rec = RouteRecognizer::new("/".to_owned(), vec![("/{key}/".to_owned(), 1)]);
let (params, _) = rec.recognize(req.path()).unwrap();
let params = params.unwrap();
let req = req.with_match_info(params);
assert_eq!(req.match_info().find("key"), Some("value"));
assert_eq!(req.match_info().get("key"), Some("value"));
}
#[test]