Closed johnmcconnell closed 7 years ago
The problem with this is that it's impossible to do reliably, because routes can contain other routes. I don't like the idea of introducing a feature that works sometimes, but not other times.
Can a route be expanded by concatenating the path of the parent route?
Or can we change the route list to a route tree?
Maybe I don't understand.
Routes are Turing-complete, so there's no way of producing a reliable routing tree from a set of Compojure routes.
I have been working on Ataraxy, a data-driven syntax for routing, and I should get back to developing that soon because I intend to use it in Duct. There are also other data-driven routing syntaxes around like Bidi.
Unfortunately Compojure's core design prevents it from being transformed into a tree of routes. Compojure is powerful, but power creates opacity.
Ahh... so are the routes like "crawled" at runtime then?
I'll take a look. Thanks!
Each route is a function that returns either a response or nil
, if the route doesn't match. You can therefore have routes that are just functions that can respond to very complex conditions.
How about only supporting this feature only for handlers defined using defroutes
?
I can implement it
I'm afraid I don't want a feature in Compojure that only works only sometimes, under specific conditions. I'd rather things either work or not.
I don't think that this is a practical feature for Compojure just as @weavejester said.
If list all available routes
is necessary, I think bidi is more suitable.
Cool. I'm looking to get this integrated with compojure-api because it currently has 'killer feature' of the auto generated swagger ui.
So I'm not willing to lose that feature by switching routing libraries.
I'll see if this feature is a better fit for that project. Thanks guys.
This is useful for testing and middleware.
For example.