This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-20
Channels
- # announcements (9)
- # aws-lambda (5)
- # babashka (26)
- # beginners (200)
- # bristol-clojurians (2)
- # calva (74)
- # cider (22)
- # clj-kondo (8)
- # cljsrn (1)
- # clojure (124)
- # clojure-australia (2)
- # clojure-europe (79)
- # clojure-spec (1)
- # clojure-uk (37)
- # clojurescript (87)
- # cloverage (1)
- # code-reviews (10)
- # conjure (41)
- # cursive (5)
- # datahike (2)
- # datascript (3)
- # datomic (11)
- # docker (4)
- # duct (1)
- # emacs (10)
- # events (1)
- # fulcro (3)
- # graalvm (1)
- # honeysql (3)
- # jobs (1)
- # malli (12)
- # meander (51)
- # off-topic (83)
- # pathom (28)
- # quil (3)
- # reagent (19)
- # reitit (3)
- # releases (1)
- # shadow-cljs (49)
- # spacemacs (2)
- # sql (5)
- # startup-in-a-month (1)
- # testing (1)
- # xtdb (8)
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?@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."})})
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.