ring-swagger & compojure-api

hey guys, quick question: is the not found advice at the end still valid? I am using compojure-api 2.0.0-alpha7 and that didnt work for me. I got it to work using an ANY handler with /* 😕


unfortunately by doing that I get a validation schema error from swagger => attribute paths.'/*'. is unexpected"

ikitommi 2017-11-06T12:10:23.000175Z

@carocad hi. can’t recall what was the not found advice… but I think this is still valid: https://github.com/weavejester/compojure#usage


@ikitommi thanks for the answer. What I am trying to do is to create a 404 handler for any request that doesnt match any handler.


unfortunately the not-found function is not called if I use it inside the compojure.api.sweet/api function. Is this a bug?


I havent tried it with a raw compojure server though. I had to do it that way because the server throws a NullPointerException otherwise

ikitommi 2017-11-06T12:15:28.000259Z

Hmm.. sound fishy. let me test.


thanks 🙂


here is our handler creation, if it helps https://github.com/hiposfer/kamal/blob/master/src/hiposfer/kamal/server.clj#L24

ikitommi 2017-11-06T12:19:17.000100Z

created a project from template and added (route/not-found "<h1>Page not found</h1>") into the end. works ok here.

ikitommi 2017-11-06T12:20:10.000267Z

compojure-api warns about non-documented route thou, wrapping that with undocumented removes the warning.

ikitommi 2017-11-06T12:21:00.000320Z

also, you could do that outside of an api: (let [app (some-fn (create grid) (route/not-found “<h1>Page not found</h1>“))] ...)


ah I found the error. There is a not-found function from compojure and there is another not-found function from compojure-api. I was mixing the two so it was not recognized


thanks @ikitommi your comments helped me figure out the confusion

ikitommi 2017-11-06T13:31:36.000370Z

np. And yes, there is the ring.util.http-response/not-found which easily get’s exported in..