Skip to content

Commit

Permalink
Rename :default-handler to :default-handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Dec 11, 2024
1 parent fdb99b1 commit 201082d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/duct/router/reitit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@
(assoc opts :path path)))

(defn- create-handlers
[{:keys [default-handler file-handlers resource-handlers]}]
[{:keys [default-handlers file-handlers resource-handlers]}]
(concat
(when file-handlers
(->> (path-map->options file-handlers)
(map ring/create-file-handler)))
(when resource-handlers
(->> (path-map->options resource-handlers)
(map ring/create-resource-handler)))
(when default-handler
(list (ring/create-default-handler default-handler)))))
(when default-handlers
(list (ring/create-default-handler default-handlers)))))

(defmethod ig/init-key :duct.router/reitit [_ options]
(let [opts (-> options
Expand Down
4 changes: 2 additions & 2 deletions test/duct/router/reitit_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
:query-params {"x" "1"}
:headers {"Accept" "application/json"}})))))

(deftest default-handler-test
(deftest default-handlers-test
(let [handler (constantly {:status 200, :body "Hello World"})
config
{:duct.router/reitit
{:routes {"/" {:get {:handler handler}}
"/406" {:handler (constantly nil)}}
:default-handler
:default-handlers
{:not-found (constantly {:status 404, :body "404"})
:method-not-allowed (constantly {:status 405, :body "405"})
:not-acceptable (constantly {:status 406, :body "406"})}}}
Expand Down

0 comments on commit 201082d

Please sign in to comment.