Closed j0ni closed 8 years ago
I'm afraid I don't know much about Compojure-API, as I'm not involved in the project, nor had reason to use the library. My guess is that you want to use the api
function in the endpoints, since it seems to return a handler, and also seems to require knowledge of the routes. However, if you want to be certain, I'd ask the Compojure-API team directly.
Thanks - I tried using the api
function in the endpoints and it did work as far as I can see. I think for a use case where there are multiple middleware stacks (maybe some endpoints that serve pages, and others that serve APIs) that's OK.
I don't think it would be as trivial of a change as I initially thought either - there's a bunch of metadata that's added as part of the api
function call which defines routes for swagger documentation and the swagger.json
API definition. That would need to be handled too.
I've just started looking at Compojure-API - if I come up with a good solution I'll follow up here. Feel free to close this unless you want to keep it bookmarked for future work.
Hey @j0ni, have you found a good way to wrap all endpoints in a single api definition in the end? I encountered a similar problem.
@sickill I haven't, though I haven't been in a situation where I cared that much since I wrote that.
I think if I had a leiningen task which reported the complete route map, a la rake routes
in rails, I'd probably have everything I needed. One thing I like about Malcolm Sparks' bidi is that the routes are a simple data structure which it's easy to pretty print (or maybe print using something like ronda-routing-bidi, which I just found). But mostly I've just continued using compojure and compojure-api and either created a single routing map in one place, or lived with the (otherwise useful) isolation provided by duct.
Thank you for duct.
I'm playing with compojure-api, and it looks like I need to apply the
compojure.api.api/api
fn here. Do you agree, or am I misunderstanding?Would you accept a PR to modify the
Handler
component to accept a handler creation fn at runtime via a component config key?