Match a path against the route table from app code (Route::getRoutes()->match())
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with the public RouteTable and RouteInfo API returned by Application::routes(); the issue names no source files or tests, so locate their definitions and existing routing tests first. Read the related #421 discussion to understand how handlers are expected to access the route table. Done means the table can distinguish a matched route, fallback, method-not-allowed, and not-found result, with the matcher accessible from handlers.
Written by the indexing model from the issue text.
Description
We're porting a production Laravel 13 (PHP) app to Laravel for Rust (laravel-rust 0.1.5). In a few places the PHP app asks the router which route a path would reach:
$route = Route::getRoutes()->match(Request::create($path)); // throws a 404/405 if nothing matches
$route->isFallback;
$route->gatherMiddleware();
We use it for three things:
- Sitemap: an SEO record's path is listed only when a guest's GET reaches a real, ungated route, never the page fallback or a login redirect.
- CMS page slugs: a slug is rejected when a route already answers that path, so a published page can't be shadowed.
- Redirect warnings: the admin is warned when a managed redirect hides a live route.
What Laravel for Rust has today (0.1.5): routing.md and urls.md cover registering routes and building URLs (route!, url::to), and route:list lists them. Nothing matches a path against the route table. Application::routes() returns a RouteTable of RouteInfo { methods, uri, domain, handler, middleware }, but:
- it isn't in the Markdown docs;
- it has no matching method;
- a handler can't reach the
Applicationto read it (#421).
Our workaround: hand-kept lists of reserved paths, plus a test that reads app.routes() and fails when the lists drift. This only works for single-segment, parameterless routes. Multi-segment routes (/settings/profile) and parameterised ones can't be covered.
Proposal: give the route table a matcher, for example
fn matches(&self, method: Method, path: &str) -> Match // Route(&RouteInfo) | Fallback(&RouteInfo) | MethodNotAllowed | NotFound
The fallback should be reported distinctly, and the matcher should be reachable from handlers through whichever accessor #421 settles on.
Related: #421 (read access to the route table from a handler).
- Dominant language
- Rust
- Stars
- 847
- Forks
- 174
- Avg merge
- 5h 40m
- Merged PRs (30d)
- 167
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from laravel/rust-framework
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
laravel/rust-framework#864 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
laravel/rust-framework#876 ·
Maintainers usually reply within 1 day
-
Case-sensitive contains, starts_with and ends_with that match % and _ literally on every databaseOpen
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#874 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
laravel/rust-framework#873 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#872 ·
Maintainers usually reply within 1 day
All issues in laravel/rust-framework
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
neuralmagic/crucible#579 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
eclipse-score/kyron#249 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
seanmonstar/reqwest#3157 ·
Maintainers usually reply within 2 days