我尝试了以下方法:
let mut router = Router:new();
router.get("/hello", |_: &mut Request| {
Ok(Response::with((status::Ok, "hello")))
}, "/hello");
let mut mount = Mount::new();
mount.mount("/", router)
.mount("/", Static::new(Path::new("src/public/")));
但是当我尝试访问时会导致“没有这样的文件或目录”错误/hello
:
Request {
url: Url { generic_url: "http://localhost:10800/hello" }
method: Get
remote_addr: V4(127.0.0.1:57260)
local_addr: V4(127.0.0.1:10800)
}
Error was: Error { repr: Os { code: 2, message: "No such file or directory" } }