Skip to content

Commit 649f338

Browse files
committed
Clarify differences between request middleware
1 parent 368ce29 commit 649f338

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ collection as a body (e.g. map, vector, set, seq, etc) into JSON:
2828
```
2929

3030
The `wrap-json-body` middleware will parse the body of any request
31-
with a JSON content-type into a Clojure data structure:
31+
with a JSON content-type into a Clojure data structure, and assign it
32+
to the `:body` key.
33+
34+
This is the preferred way of handling JSON requests.
3235

3336
```clojure
3437
(use '[ring.middleware.json :only [wrap-json-body]]
@@ -43,10 +46,11 @@ with a JSON content-type into a Clojure data structure:
4346
```
4447

4548

46-
The `wrap-json-params` middleware will parse any request with a JSON
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:
49+
The `wrap-json-params` middleware is an alternative to
50+
`wrap-json-body` for when it's convenient to treat a JSON request as a
51+
map of parameters. Rather than replace the `:body` key, the parsed
52+
data structure will be assigned to the `:json-params`. The parameters
53+
will also be merged into the standard `:params` map.
5054

5155
```clojure
5256
(require '[ring.middleware.json :refer [wrap-json-params]]

0 commit comments

Comments
 (0)