reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
paulbutcher 2021-01-20T00:47:21.058500Z

I suspect I’m missing something, but I’m unable to get the :not-found-handler option for reitit.ring/create-resource-handler to work: it doesn’t look like the function is called at all. I’ve created a minimal cut-down version of my application which demostrates the problem: https://github.com/paulbutcher/reitit-bug The relevant code is:

(def handler
  (ring/ring-handler
   (ring/router
    ["/ping" {:get (constantly (response "pong"))}])
   (ring/routes
    (ring/create-resource-handler {:path "/"
                                   :not-found-handler (fn [x]
                                                        (println "not found handler: " x)
                                                        (-> "index.html"
                                                            (resource-response {:root "public"})
                                                            (content-type "text/html")))})
    (ring/create-default-handler))))
What am I missing?

Steven Deobald 2021-01-20T19:22:09.059300Z

@paulbutcher Just passing by but at a glance, my routes file has :not-found in the default handler itself:

(rr/create-default-handler
     {:not-found          (constantly {:status 404, :body "404: Not Found."})
      :method-not-allowed (constantly {:status 405, :body "405: Method Not Allowed."})
      :not-acceptable     (constantly {:status 406, :body "406: Not Acceptable."})})

paulbutcher 2021-01-20T22:04:03.061Z

Thanks @steven427. I’m aware that that’s possible too (and indeed that’s the solution that I’ve settled on). But create-resource-handler claims to also support this functionality and doesn’t seem to be working for me at least.