mirror of https://github.com/fafhrd91/actix-web
add test for nested route
This commit is contained in:
parent
45b57816ee
commit
90add4ca26
|
@ -135,6 +135,7 @@ impl HttpRequest {
|
|||
#[inline]
|
||||
pub fn match_pattern(&self) -> Option<String> {
|
||||
self.0.rmap.match_pattern(self.path())
|
||||
}
|
||||
|
||||
/// Checks if a given path matches a route
|
||||
#[inline]
|
||||
|
@ -645,14 +646,14 @@ mod tests {
|
|||
move |req: HttpRequest| {
|
||||
assert_eq!(
|
||||
req.match_name(),
|
||||
Some("/user/{id}/profile".to_owned())
|
||||
Some(&ResourceDef::new("/profile"))
|
||||
);
|
||||
|
||||
HttpResponse::Ok().finish()
|
||||
},
|
||||
)))
|
||||
.default_service(web::to(move |req: HttpRequest| {
|
||||
assert!(req.match_pattern().is_none());
|
||||
assert!(req.match_name().is_none());
|
||||
HttpResponse::Ok().finish()
|
||||
})),
|
||||
),
|
||||
|
|
|
@ -195,7 +195,13 @@ impl ServiceRequest {
|
|||
pub fn match_info(&self) -> &Path<Url> {
|
||||
self.0.match_info()
|
||||
}
|
||||
|
||||
|
||||
/// Counterpart to [`HttpRequest::match_name`](../struct.HttpRequest.html#method.match_name).
|
||||
#[inline]
|
||||
pub fn match_name(&self) -> Option<&ResourceDef> {
|
||||
self.0.match_name()
|
||||
}
|
||||
|
||||
/// Counterpart to [`HttpRequest::match_pattern`](../struct.HttpRequest.html#method.match_pattern).
|
||||
#[inline]
|
||||
pub fn match_pattern(&self) -> Option<String> {
|
||||
|
|
Loading…
Reference in New Issue