Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Merge commit '39a9d2279ea422e203b5359c11b050098e8ca90a' into aykuznet…
Browse files Browse the repository at this point in the history
…sova/use-custom-handle-error
  • Loading branch information
ngrunwald committed Mar 27, 2015
2 parents db33a63 + 39a9d22 commit 51ab1a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ring/middleware/format_params.clj
Expand Up @@ -128,7 +128,7 @@
:predicate predicate
:decoder decoder
:charset charset
:handle-error default-handle-error))
:handle-error handle-error))

(defn wrap-json-kw-params
"Handles body params in JSON format. Parses map keys as keywords.
Expand All @@ -142,7 +142,7 @@
:predicate predicate
:decoder (fn [struct] (decoder struct true))
:charset charset
:handle-error default-handle-error))
:handle-error handle-error))

(def ^:no-doc yaml-request?
(make-type-request-pred #"^(application|text)/(vnd.+)?(x-)?yaml"))
Expand Down
12 changes: 12 additions & 0 deletions test/ring/middleware/format_params_test.clj
Expand Up @@ -165,3 +165,15 @@
(fn [request]
(is (nil? (:body request)))))
{:body nil}))

(deftest test-custom-handle-error
(are [format content-type body]
(let [req {:body body
:content-type content-type}
resp ((wrap-restful-params identity
:formats [format]
:handle-error (constantly {:status 999}))
req)]
(= 999 (:status resp)))
:json "application/json" "{:a 1}"
:edn "application/edn" "{\"a\": 1}"))

0 comments on commit 51ab1a4

Please sign in to comment.