diff --git a/README.md b/README.md index c5705d6b..ff89d226 100644 --- a/README.md +++ b/README.md @@ -560,7 +560,7 @@ To demonstrate the two approaches, below are response coercion middleware writte responses (-> match :result method :meta :responses) coercion (-> match :meta :coercion) opts (-> match :meta :opts)] - (if coercion + (if (and coercion responses) (let [coercers (response-coercers coercion responses opts) coerced (coerce-response coercers request response)] (coerce-response coercers request (handler request))) @@ -572,7 +572,7 @@ To demonstrate the two approaches, below are response coercion middleware writte responses (-> match :result method :meta :responses) coercion (-> match :meta :coercion) opts (-> match :meta :opts)] - (if coercion + (if (and coercion responses) (let [coercers (response-coercers coercion responses opts) coerced (coerce-response coercers request response)] (handler request #(respond (coerce-response coercers request %)))) diff --git a/src/reitit/coercion.cljc b/src/reitit/coercion.cljc index c2c0c901..4879f50a 100644 --- a/src/reitit/coercion.cljc +++ b/src/reitit/coercion.cljc @@ -115,7 +115,7 @@ match (ring/get-match request) parameters (-> match :result method :meta :parameters) coercion (-> match :meta :coercion)] - (if coercion + (if (and coercion parameters) (let [coercers (request-coercers coercion parameters) coerced (coerce-parameters coercers request)] (handler (impl/fast-assoc request :parameters coerced))) @@ -125,7 +125,7 @@ match (ring/get-match request) parameters (-> match :result method :meta :parameters) coercion (-> match :meta :coercion)] - (if coercion + (if (and coercion parameters) (let [coercers (request-coercers coercion parameters) coerced (coerce-parameters coercers request)] (handler (impl/fast-assoc request :parameters coerced) respond raise))))))) @@ -161,7 +161,7 @@ responses (-> match :result method :meta :responses) coercion (-> match :meta :coercion) opts (-> match :meta :opts)] - (if coercion + (if (and coercion responses) (let [coercers (response-coercers coercion responses opts) coerced (coerce-response coercers request response)] (coerce-response coercers request (handler request))) @@ -173,7 +173,7 @@ responses (-> match :result method :meta :responses) coercion (-> match :meta :coercion) opts (-> match :meta :opts)] - (if coercion + (if (and coercion responses) (let [coercers (response-coercers coercion responses opts) coerced (coerce-response coercers request response)] (handler request #(respond (coerce-response coercers request %))))