Better routing #8

Closed
opened 2024-02-08 15:36:36 +01:00 by Jef Roosens · 1 comment

Regex isn't the best solution for matching routes, as it's rather cpu intensive. Instead, I'd like to implement parametrized routes using a trie-like structure, which would hopefully be much faster than the current methods.

This would support the usual expected stuff, /:var for matching a single keyword, or /*var for matching multiple segments.

Together with this, I'd like to introduce "routers", structs that allow defining multiple grouped routes which can then all be mapped to the same subpath on the main router, eg putting all /api routes into a single router.

To do

  • Literal string matching

  • Single-segment wildcard matching

  • Output wildcard segment matches

  • Replace old router with new one

  • Add API functions for retrieving matched segments

Regex isn't the best solution for matching routes, as it's rather cpu intensive. Instead, I'd like to implement parametrized routes using a trie-like structure, which would hopefully be much faster than the current methods. This would support the usual expected stuff, `/:var` for matching a single keyword, or `/*var` for matching multiple segments. Together with this, I'd like to introduce "routers", structs that allow defining multiple grouped routes which can then all be mapped to the same subpath on the main router, eg putting all `/api` routes into a single router. ## To do - [x] Literal string matching - [x] Single-segment wildcard matching - [x] Output wildcard segment matches - [ ] Replace old router with new one - [x] Add API functions for retrieving matched segments
Jef Roosens added the
enhancement
label 2024-02-08 15:36:36 +01:00
Jef Roosens added reference routing 2024-02-22 18:20:44 +01:00

For the API for accessing matched variables, we should introduce a trie for matching the variable names so they can be referenced using their names.

For the API for accessing matched variables, we should introduce a trie for matching the variable names so they can be referenced using their names.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Chewing_Bever/lnm#8
There is no content yet.