reitit icon indicating copy to clipboard operation
reitit copied to clipboard

Add regex based router

Open danielcompton opened this issue 10 months ago • 1 comments

Reitit is very fast, but cannot support all routing structures that other routers like Bidi support, particular regex-based routes.

This PR is a proof of concept of one way that a regex based router could work with Reitit.

A more complete version of this PR would compile only the regex based routes to this router, and let the rest of the routes be handled by faster Reitit routers. You could also compile the regex based router to match on a path segment at a time, pruning routes before needing to evaluate a regular expression.

Before I go too much further, I wanted to get some feedback on the syntax for route definition and the overall approach. What do you think about this idea, and the way that path parameters are defined as regex's?

This unoptimized router is about 8-20x slower than regular Reitit in some informal testing.

Fixes https://github.com/metosin/reitit/issues/722

danielcompton avatar Feb 25 '25 09:02 danielcompton

This could be also interesting for frontend use, to optimize the artifact size (#540) because the Trie implementation generates quite a lot of JS code and the performance doesn't matter as much for FE routing.

I'll try to review this at some point.

Deraen avatar Mar 28 '25 13:03 Deraen