Fork me on GitHub

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: The relevant code is:

(def handler
    ["/ping" {:get (constantly (response "pong"))}])
    (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")))})
What am I missing?

Steven Deobald19:01:09

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

     {: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."})})


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.