-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
* route priority #593
Comments
I believe this is the same issue as #595 — if you add a distinct prefix to the dynamic route, like |
That's not really doable for me though because I'm not building an api, I need the paths to be what users see because I'm rendering templates. The /static route needs to exist for the templates o pull in css files
|
Does this work? That is, switching registration order? pub(crate) fn setup(app: &mut Server<StateRef>, root: PathBuf) {
app.at("/static").serve_dir(root.join("static")).unwrap();
app.at("/:owner/:repo").get(|_| async move { Ok("Hello world!") });
}
|
I've reproduced this problem and I'm not sure what the right solution is, but here's an update. Route prioritization exists in route-recognizer. (edit: I hadn't realized that this was under the http-rs umbrella when I wrote this comment, so it's possible we could change this behavior) This issue can be reduced to the following failing test (using the test helpers in #601 for convenience): #[async_std::test]
async fn static_routing() {
let mut app = tide::Server::new();
app.at("/:one/:two").get("two segments");
app.at("/a/*").get("static + star");
assert_eq!(app.get_body("/a/a").await, "static + star");
} which results in
Of note, route-recognizer is not order dependent, and instead uses a relative priority comparison that in this case is not what we want. |
Update: This is fixed in route-recognizer master, so we just need them to publish a patch release |
@spacekookie If you get a chance, could you confirm that this is fixed in tide master? Thanks! |
The main branch doesn't work for me because i'm getting this error:
My [package]
name = "octopus"
description = "A lightweight web frontend for git repositories"
version = "0.1.0"
authors = ["Katharina Fey <kookie@spacekookie.de>"]
edition = "2018"
[dependencies]
tide = { git = "https://github.com/http-rs/tide" } |
does cargo update resolve that? |
Currently
serde_dir()
seems to be broken. It works if it is the only route in an app, but fails to is never routed to when it's not.This works, but the following does not:
The text was updated successfully, but these errors were encountered: