tide
tide copied to clipboard
make Request::rest public outside of the crate
closes #426
You can use app.all
to match everything:
app.at("*").all(endpoint);
Is there still something missing?
This is a different concern. Sorry I was unclear. Within a route handler with a "/nested/*" route, how do I get access to the entirety of the globbed part? (Not the request.uri(), just the unnamed * "param")
Haven't quite understood your problem, but maybe you're aiming for /nested/*path
which will give you the rest of the request path under /nested/
in a path
param. You can then get it as any other param with req.param("path")...
.
use tide::Request;
use async_std::task;
fn main() {
let mut app = tide::new();
app.at("/nested/*path").get(|req: Request<()>| async move {
let path: String = req.param("path").unwrap();
println!("{}", path);
path
});
task::block_on(app.listen("127.0.0.1:18888")).unwrap();
}
Worked with this request:
curl -vvv 'localhost:18888/nested//ds/da((*&^/ds'
And the response is:
/ds/da((*&^/ds
As I mentioned in the issue, the param parser supports unnamed star globs, and they’re also mentioned in the tide docs, and as far as I can tell, tide stores them and has a method that is unused within the crate which does exactly this, but is pub(crate).
Perhaps the solution is just to remove mention of unnamed globs from the docs, also the rest method and --tide-path-rest
. It seems quite reasonable not to support them