nette / routing

Nette Routing: two-ways URL conversion
https://doc.nette.org/routing
Other
231 stars 3 forks source link

Add prependRoute method #13

Open thorewi opened 2 years ago

thorewi commented 2 years ago

Hi,

in ErrorPresenter I create catchall route looking like this [<url .*>] to get {link this} or {link 404!} working in the error template. But I need to prepend it to avoid the request being consumed by another route (looking like this <presenter>/<action>[/<id>] for example). I need to avoid using Route constructor that's why I can't use prepend method which needs it (every RouteList can use different Route class). I need to create the route in a way addRoute method is doing this. If you think it is a good idea, I can create PR. Thank you.

mabar commented 1 year ago

Not sure, if you chose the right way to solve that problem. How would be a prepend different from defining the route first in the list? Also if the route catches everything then routes after that one would never match. To make route generating work for an error presenter just create e.g. /error route. I don't think you even need error codes, because you don't want user to be able to control codes and for general error it is okay to just have 404 code