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

better query() method impl; update doc strings

This commit is contained in:
Nikolay Kim
2017-12-19 11:34:51 -08:00
parent 009874125e
commit 2bad99b645
2 changed files with 44 additions and 9 deletions

View File

@ -317,10 +317,18 @@ resource with the name "foo" and the pattern "{a}/{b}/{c}", you might do this.
# use actix_web::httpcodes::*;
#
fn index(req: HttpRequest) -> HttpResponse {
let url = req.url_for("foo", &["1", "2", "3"]);
HTTPOk.into()
let url = req.url_for("foo", &["1", "2", "3"]); // <- generate url for "foo" resource
HTTPOk.into()
}
fn main() {
let app = Application::new()
.resource("/test/{one}/{two}/{three}", |r| {
r.name("foo"); // <- set resource name, then it could be used in `url_for`
r.method(Method::GET).f(|_| httpcodes::HTTPOk);
})
.finish();
}
# fn main() {}
```
This would return something like the string *http://example.com/1/2/3* (at least if