question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`app.showRoutes()` has duplicate routes when middleware is used

See original GitHub issue

Example code

app.get("/a", someMiddleWare, (c) => { 
  new Response("a");
})
app.showRoutes();

app.showRoutes() outputs:

GET    /a
GET    /a

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
yusukebecommented, Nov 27, 2022

Would it be possible to add a parameter for the showRoutes method not to show duplicate routes if that’s what the developer wants?

Yes. But I don’t want to give the options to developers for the showRoutes to make this simple. And it may make the code verbose mentioned above. In this case, the problem is the developer may feel, “Is this bug?”.

For example, there could be a more clear way to show the routes, such as changing the color, numbering, and so on. However, we don’t know the best way.

0reactions
yusukebecommented, Dec 10, 2022

I personally think the ideal representation would be something like this: Just to distinguish better which routes are middleware and which routes are actual endpoints.

Yes, of course, I also want to do that, but I could not implement it like that, I think there is no way:(

Read more comments on GitHub >

github_iconTop Results From Across the Web

laravel - Resolve duplicate routes based on middleware group
In web.php I have two middleware groups for two user roles - admins and non_admins : ... My guess: Laravel sees the two...
Read more >
Detecting duplicate routes in ASP.NET Core
In this post I show how you can use a unit test to identify duplicate routes that would fail at runtime.
Read more >
Routing - Laravel - The PHP Framework For Web Artisans
The routes in routes/api.php are stateless and are assigned the api middleware group. For most applications, you will begin by defining routes in...
Read more >
FAQ: Middleware - Route-Level app.use() - Multiple Paths
This community-built FAQ covers the “Route-Level app.use() - Multiple Paths” exercise from the lesson “Middleware”. Paths and Courses
Read more >
Routing in ASP.NET Core - Microsoft Learn
Routing is responsible for matching incoming HTTP requests and dispatching those requests to the app's executable endpoints.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found