Rocket 网站上的指南建议可以对动态路线进行排名。该示例使用不同类型的动态部分作为路由的匹配条件。当我将 url 与 a 以外的任何内容一起放置时usize
,我收到以下错误:
GET /user/three text/html:
=> Matched: GET /user/<id>
=> Failed to parse 'id': RawStr("three")
=> Outcome: Forward
=> Error: No matching routes for GET /user/three text/html.
=> Warning: Responding with 404 Not Found catcher.
=> Response succeeded.
我正在使用的代码:
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
use rocket::http::RawStr;
#[get("/user/<id>")]
fn user(id: usize) -> String { format!("First rank") }
#[get("/user/<id>", rank = 2)]
fn user_int(id: isize) -> String { format!("second rank") }
#[get("/user/<id>", rank = 3)]
fn user_str(id: &RawStr) -> String { format!("last rank") }
fn main() {
rocket::ignite().mount("/", routes![user]).launch();
}
我希望在显示测试时不是404 error
一个页面。为什么不这样做?/user/three
last rank