Skip to content

Commit fb72503

Browse files
committed
lazily load coercion extensions
1 parent 965aff2 commit fb72503

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
See also: [compojure-api 1.1.x changelog](./CHANGELOG-1.1.x.md)
22

3+
## Next
4+
* Lazily load spec and schema coercion support to preserve Clojure 1.8 support for 1.1.x
5+
36
## 2.0.0-alpha34-SNAPSHOT
47
* **BREAKING CHANGE**: `:formatter :muuntaja` sometimes required for `api{-middleware}` options
58
* to prepare for 1.x compatibility, :muuntaja must be explicitly configured

src/compojure/api/coercion.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
[compojure.api.exception :as ex]
44
[compojure.api.request :as request]
55
[compojure.api.coercion.core :as cc]
6-
[compojure.api.coercion.schema]
7-
[compojure.api.coercion.spec])
6+
;; side effects
7+
compojure.api.coercion.register-schema
8+
compojure.api.coercion.register-spec)
89
(:import (compojure.api.coercion.core CoercionError)))
910

1011
(def default-coercion :schema)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(ns compojure.api.coercion.register-schema
2+
(:require [compojure.api.coercion.core :as cc]))
3+
4+
(defmethod cc/named-coercion :schema [_]
5+
(deref
6+
(or (resolve 'compojure.api.coercion.schema/default-coercion)
7+
(do (require 'compojure.api.coercion.schema)
8+
(resolve 'compojure.api.coercion.schema/default-coercion)))))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(ns compojure.api.coercion.register-spec
2+
(:require [compojure.api.coercion.core :as cc]))
3+
4+
(defmethod cc/named-coercion :spec [_]
5+
(deref
6+
(or (resolve 'compojure.api.coercion.spec/default-coercion)
7+
(do (require 'compojure.api.coercion.spec)
8+
(resolve 'compojure.api.coercion.spec/default-coercion)))))

src/compojure/api/coercion/schema.clj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,3 @@
8484
(->SchemaCoercion :schema options))
8585

8686
(def default-coercion (create-coercion default-options))
87-
88-
(defmethod cc/named-coercion :schema [_] default-coercion)

src/compojure/api/coercion/spec.clj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,3 @@
149149
(->SpecCoercion :spec options))
150150

151151
(def default-coercion (create-coercion default-options))
152-
153-
(defmethod cc/named-coercion :spec [_] default-coercion)

0 commit comments

Comments
 (0)