Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 html 页面上有一个包含用户列表的表格。如何生成指向显示单个用户信息的页面的链接?“/用户/:用户名”?
当然,我可以对其进行硬编码。但我想在 Iron 的帮助下生成更安全。
Iron 的路由器有两个协同工作的宏。
router!允许您使用键定义路由:
router!
let router = router!(index: get "/" => index, query: get "/:query" => queryHandler, post: post "/" => postHandler);
url_for!允许您为密钥生成 URL:
url_for!
url_for!(request, "foo", "query" => "test", "extraparam" => "foo")