Tide: Consider using route_recognizer instead of path-table

Created on 26 Feb 2019  路  6Comments  路  Source: http-rs/tide

Detailed Description

For now Router is using path-table for its route matching. Consider changing the algorithm by replacing it with [route_recognizer].

The published version of route_recognizer is unmaintained for about 2 years, and seems to have reversed precedence of path segment matching (conduit-rust/route-recognizer.rs#21). Maybe we can fork the repository and apply some patches.

Context

Related to #12. route_recognizer seems to have more sophiscated route matching algorithm than path-table. I expect it to fix most of the counterintuitive cases.

Most helpful comment

I wrote a crate https://github.com/trek-rs/path-tree.

Currently, I am thinking about how to generate urls. Maybe the {} is best syntax.

All 6 comments

There is actix_router, but it is Independent锛宎nd dont dependent Actix* . It is General
this is one test

Note: this is the algorithm ultimately used by crates.io:

so it's "maintained", just hasn't needed a lot of updating. Definitely a worthy candidate to look at, and I expect the current owners would be interested in moving it into the rust-net-web org.

One thing to consider for the router API is a way of providing reverse lookups #24. I'll go into more detail about the small survey I did of current implementation of such an API in django and flask, but both of them leverage the router to provide a reverse lookups of endpoints to paths for building URLs.

So, we need a router that:

  • has intuitive path matching algorithm
  • can be nested
  • has ability to perform reverse lookups

path-table currently used by Tide addresses only the second point, and both route_recognizer and actix-router don't have reverse lookup feature (as far as I understand). I think we need to fork and add needed functionality anyway, so how about experimenting with route_recognizer? It might be challenging with state machines, though.

I wrote a crate https://github.com/trek-rs/path-tree.

Currently, I am thinking about how to generate urls. Maybe the {} is best syntax.

The #156 PR moved to route-recognizer. And in general it should now be much easier to swap out the underlying router. I'm open to moving to path-tree if that seems like a better option -- though offhand the two seem pretty comparable in terms of functionality (and route-recognizer is used by crates.io, so there's some impetus for sharing).

I'm going to close this for now, but if @fundon or others want to explore moving from route-recognizer to path-tree or something else, please feel free to open a new issue and make a case there!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gruberb picture gruberb  路  4Comments

alexreg picture alexreg  路  5Comments

friktor picture friktor  路  3Comments

lichr picture lichr  路  4Comments

secretfader picture secretfader  路  3Comments