Documentation about url_for.
Code:
fn index(req: HttpRequest) -> HttpResponse {
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();
}
How can I add to generated URL a query string like ?name=Alex
? Is there a nice built in way to do it using HttpRequest.url_for()
(not just append like url += query_str
)