You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,9 +152,21 @@ There is also `defapi` as a short form for the common case of defining routes wi
152
152
153
153
## Request & response formats
154
154
155
-
Middlewares (and other handlers) can publish their capabilities to consume & produce different wire-formats. This information is passed to `ring-swagger` and added to swagger-docs & is available in the swagger-ui.
155
+
Middlewares (and other handlers) can publish their capabilities to consume & produce different wire-formats.
156
+
This information is passed to `ring-swagger` and added to swagger-docs & is available in the swagger-ui.
156
157
157
-
One can add own format middlewares (XML, EDN etc.) and add expose their capabilities by adding the supported content-type into request under keys `[:meta :consumes]` and `[:meta :produces]` accordingly.
158
+
The default middleware on Compojure-API includes [ring-middleware-format](https://github.com/ngrunwald/ring-middleware-format)
159
+
which supports multiple formats. If the first element of `defapi` body is a map it will be used to pass parameters to
160
+
`api-middleware`, e.g. the formats which should be enabled.
161
+
162
+
```clojure
163
+
(defapiapp
164
+
{:formats [:transit-json:edn]}
165
+
(context"/api" [] ...))
166
+
```
167
+
168
+
One can add own format middlewares (XML etc.) and add expose their capabilities by adding the
169
+
supported content-type into request under keys `[:meta :consumes]` and `[:meta :produces]` accordingly.
158
170
159
171
## Routes
160
172
@@ -369,7 +381,10 @@ Key `:responses` takes a map of http-status-code -> model map, which translates
369
381
370
382
## Route-specific middlewares
371
383
372
-
Key `:middlewares` takes a vector of middlewares to be applied to the route. Note that the middlewares are wrapped around the route, so they don't see any restructured bindinds from within the route body and they **are applied before the actual route is being matched**.
384
+
Key `:middlewares` takes a vector of middlewares to be applied to the route.
385
+
Note that the middlewares don't see any restructured bindinds from within the route body.
386
+
They are executed inside the route so you can safely edit request etc. and the changes
0 commit comments