Skip to content

Commit 4c5c260

Browse files
committed
undo rmf compat
1 parent 113263b commit 4c5c260

File tree

1 file changed

+3
-58
lines changed

1 file changed

+3
-58
lines changed

src/compojure/api/middleware.clj

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@
8989
;; Options
9090
;;
9191

92-
;; 1.1.x
93-
(defn get-options
94-
"Extracts compojure-api options from the request."
95-
[request]
96-
(::options request))
97-
9892
(defn wrap-inject-data
9993
"Injects data into the request."
10094
[handler data]
@@ -124,13 +118,6 @@
124118
(def no-response-coercion
125119
(constantly (dissoc default-coercion-matchers :response)))
126120

127-
(defn coercion-matchers [request]
128-
(let [options (get-options request)]
129-
(if (contains? options :coercion)
130-
(if-let [provider (:coercion options)]
131-
(provider request))
132-
default-coercion-matchers)))
133-
134121
;;
135122
;; Muuntaja
136123
;;
@@ -219,8 +206,7 @@
219206
;;
220207

221208
(def api-middleware-defaults
222-
{::api-middleware-defaults true
223-
:formats ::default
209+
{:formats ::default
224210
:exceptions {:handlers {:ring.util.http-response/response ex/http-response-handler
225211
::ex/request-validation ex/request-validation-handler
226212
::ex/request-parsing ex/request-parsing-handler
@@ -258,21 +244,12 @@
258244
259245
### Options
260246
261-
- **:formatter** either :ring-middleware-format or :muuntaja.
262-
During 2.x pre-releases, this will be a required key, unless
263-
:formats is provided, which is equivalent to setting to :muuntaja.
264-
Stable 2.x releases will default to :ring-middleware-format if
265-
not provided or :format is set, unless :formats is provided,
266-
which is equivalent to setting to :muuntaja.
267-
Stable 2.x will print a deprecation warning if implicitly
268-
or explicitly set to :ring-middleware-format.
269-
270247
- **:exceptions** for *compojure.api.middleware/wrap-exceptions* (nil to unmount it)
271248
- **:handlers** Map of error handlers for different exception types, type refers to `:type` key in ExceptionInfo data.
272249
273250
- **:formats** for Muuntaja middleware. Value can be a valid muuntaja options-map,
274251
a Muuntaja instance or nil (to unmount it). See
275-
https://github.com/metosin/muuntaja/blob/master/doc/Configuration.md for details.
252+
https://github.com/metosin/muuntaja/wiki/Configuration for details.
276253
277254
- **:middleware** vector of extra middleware to be applied last (just before the handler).
278255
@@ -289,41 +266,9 @@
289266
you might want to take look at using wrap-components
290267
middleware manually.). Defaults to nil (middleware not mounted)."
291268
([handler]
292-
(throw (ex-info (str "ERROR: Please set `:formatter :muuntaja` in the options map of `api-middleware.\n"
293-
"e.g., (api-middleware <handler> {:formatter :muuntaja})\n"
294-
"To prepare for backwards compatibility with compojure-api 1.x, the formatting library must be \n"
295-
"explicitly chosen if not configured by `:format` (ring-middleware-format) or\n"
296-
"`:formats` (muuntaja). Once 2.x is stable, the default will be `:formatter :ring-middleware-format`.")
297-
{}))
298269
(api-middleware handler api-middleware-defaults))
299270
([handler options]
300-
(when (and (::api-middleware-defaults options)
301-
(not (:formatter options))
302-
(not (System/getProperty "compojure.api.middleware.global-default-formatter")))
303-
(throw (ex-info (str "ERROR: Please set `:formatter :muuntaja` in the options map of `api-middleware.\n"
304-
"e.g., (api-middleware <handler> {:formatter :muuntaja})\n"
305-
"To prepare for backwards compatibility with compojure-api 1.x, the formatting library must be\n"
306-
"explicitly chosen if not configured by `:format` (ring-middleware-format) or\n"
307-
":formats (muuntaja). Once 2.x is stable, the default will be `:formatter :ring-middleware-format`.\n"
308-
"To globally override the default formatter, use -Dcompojure.api.middleware.global-default-formatter=:muuntaja")
309-
{})))
310-
(let [formatter (or (:formatter options)
311-
(when (or (contains? options :formats)
312-
(= (System/getProperty "compojure.api.middleware.global-default-formatter")
313-
":muuntaja"))
314-
:muuntaja)
315-
(throw (ex-info (str "ERROR: Please set `:formatter :muuntaja` in the options map of `api-middleware.\n"
316-
"e.g., (api-middleware <handler> {:formatter :muuntaja})\n"
317-
"To prepare for backwards compatibility with compojure-api 1.x, the formatting library must be\n"
318-
"explicitly chosen if not configured by `:format` (ring-middleware-format) or\n"
319-
":formats (muuntaja). Once 2.x is stable, the default will be `:formatter :ring-middleware-format`.\n"
320-
"To globally override the default formatter, use -Dcompojure.api.middleware.global-default-formatter=:muuntaja")
321-
{}))
322-
;; TODO 2.x stable
323-
:ring-middleware-format)
324-
_ (assert (= :muuntaja formatter)
325-
(str "Invalid :formatter: " (pr-str formatter) ". Must be :muuntaja."))
326-
options (api-middleware-options options)
271+
(let [options (api-middleware-options options)
327272
{:keys [exceptions components formats middleware ring-swagger coercion]} options
328273
muuntaja (create-muuntaja formats)]
329274

0 commit comments

Comments
 (0)