kemalcr / kemal

Fast, Effective, Simple Web Framework

Home Page:https://kemalcr.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any possibility of allowing duplicate routes?

u89012 opened this issue · comments

I'm exploring generating some standard crud routes (legacy database, hundreds of tables) some of which I then intend to override (by redeclaring and thus overwriting the generated one) but Kemal won't let me declare duplicate routes. Any possibility this feature could be added? Kemal could warn of duplicates overwriting the previous definition thus alerting and not outright failing. Much thanks!

Duplicate routes are possible only when you have a difference in the prefix, when you define a route you prefix it with the request method which will be handled by the context call of the RouteHandler, it looks up the route via request_method + path and returns a Route struct which contains the proc of the endpoint and executes it.

If you want duplicate routes you should use different prefixes as in different HTTP methods to declare multiple same routes but different ways of getting there, (GET "/", POST "/", etc.)

Otherwise declaring (GET "/" and GET "/") is just confusing to the Radix tree.

No, I don't think we'll support duplicate routes.