Skip to content

Commit 368ce29

Browse files
committed
Add note about keywords in wrap-json-params
1 parent b29f321 commit 368ce29

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ with a JSON content-type into a Clojure data structure:
4444

4545

4646
The `wrap-json-params` middleware will parse any request with a JSON
47-
content-type and body and merge the resulting parameters into a params
48-
map:
47+
content-type and body. A map is expected, and will be assigned to the
48+
`:json-params` key on the request map. The parameters will also be
49+
merged into the standard `:params` map:
4950

5051
```clojure
5152
(require '[ring.middleware.json :refer [wrap-json-params]]
@@ -59,6 +60,19 @@ map:
5960
(wrap-json-params handler))
6061
```
6162

63+
Note that Ring parameter maps use strings for keys. For consistency,
64+
this means that `wrap-json-params` does not have a `:keywords?`
65+
option. Instead, use the standard Ring `wrap-keyword-params` function:
66+
67+
```clojure
68+
(require '[ring.middleware.keyword-params :refer [wrap-keyword-params]])
69+
70+
(def app
71+
(-> handler
72+
wrap-keyword-params
73+
wrap-json-params))
74+
```
75+
6276
## License
6377

6478
Copyright © 2015 James Reeves

0 commit comments

Comments
 (0)