mirror of
https://github.com/metosin/reitit.git
synced 2025-12-23 02:41:10 +00:00
coercion & responses
This commit is contained in:
parent
07c96d2b0d
commit
dc06c25cae
2 changed files with 6 additions and 6 deletions
|
|
@ -560,7 +560,7 @@ To demonstrate the two approaches, below are response coercion middleware writte
|
||||||
responses (-> match :result method :meta :responses)
|
responses (-> match :result method :meta :responses)
|
||||||
coercion (-> match :meta :coercion)
|
coercion (-> match :meta :coercion)
|
||||||
opts (-> match :meta :opts)]
|
opts (-> match :meta :opts)]
|
||||||
(if coercion
|
(if (and coercion responses)
|
||||||
(let [coercers (response-coercers coercion responses opts)
|
(let [coercers (response-coercers coercion responses opts)
|
||||||
coerced (coerce-response coercers request response)]
|
coerced (coerce-response coercers request response)]
|
||||||
(coerce-response coercers request (handler request)))
|
(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)
|
responses (-> match :result method :meta :responses)
|
||||||
coercion (-> match :meta :coercion)
|
coercion (-> match :meta :coercion)
|
||||||
opts (-> match :meta :opts)]
|
opts (-> match :meta :opts)]
|
||||||
(if coercion
|
(if (and coercion responses)
|
||||||
(let [coercers (response-coercers coercion responses opts)
|
(let [coercers (response-coercers coercion responses opts)
|
||||||
coerced (coerce-response coercers request response)]
|
coerced (coerce-response coercers request response)]
|
||||||
(handler request #(respond (coerce-response coercers request %))))
|
(handler request #(respond (coerce-response coercers request %))))
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@
|
||||||
match (ring/get-match request)
|
match (ring/get-match request)
|
||||||
parameters (-> match :result method :meta :parameters)
|
parameters (-> match :result method :meta :parameters)
|
||||||
coercion (-> match :meta :coercion)]
|
coercion (-> match :meta :coercion)]
|
||||||
(if coercion
|
(if (and coercion parameters)
|
||||||
(let [coercers (request-coercers coercion parameters)
|
(let [coercers (request-coercers coercion parameters)
|
||||||
coerced (coerce-parameters coercers request)]
|
coerced (coerce-parameters coercers request)]
|
||||||
(handler (impl/fast-assoc request :parameters coerced)))
|
(handler (impl/fast-assoc request :parameters coerced)))
|
||||||
|
|
@ -125,7 +125,7 @@
|
||||||
match (ring/get-match request)
|
match (ring/get-match request)
|
||||||
parameters (-> match :result method :meta :parameters)
|
parameters (-> match :result method :meta :parameters)
|
||||||
coercion (-> match :meta :coercion)]
|
coercion (-> match :meta :coercion)]
|
||||||
(if coercion
|
(if (and coercion parameters)
|
||||||
(let [coercers (request-coercers coercion parameters)
|
(let [coercers (request-coercers coercion parameters)
|
||||||
coerced (coerce-parameters coercers request)]
|
coerced (coerce-parameters coercers request)]
|
||||||
(handler (impl/fast-assoc request :parameters coerced) respond raise)))))))
|
(handler (impl/fast-assoc request :parameters coerced) respond raise)))))))
|
||||||
|
|
@ -161,7 +161,7 @@
|
||||||
responses (-> match :result method :meta :responses)
|
responses (-> match :result method :meta :responses)
|
||||||
coercion (-> match :meta :coercion)
|
coercion (-> match :meta :coercion)
|
||||||
opts (-> match :meta :opts)]
|
opts (-> match :meta :opts)]
|
||||||
(if coercion
|
(if (and coercion responses)
|
||||||
(let [coercers (response-coercers coercion responses opts)
|
(let [coercers (response-coercers coercion responses opts)
|
||||||
coerced (coerce-response coercers request response)]
|
coerced (coerce-response coercers request response)]
|
||||||
(coerce-response coercers request (handler request)))
|
(coerce-response coercers request (handler request)))
|
||||||
|
|
@ -173,7 +173,7 @@
|
||||||
responses (-> match :result method :meta :responses)
|
responses (-> match :result method :meta :responses)
|
||||||
coercion (-> match :meta :coercion)
|
coercion (-> match :meta :coercion)
|
||||||
opts (-> match :meta :opts)]
|
opts (-> match :meta :opts)]
|
||||||
(if coercion
|
(if (and coercion responses)
|
||||||
(let [coercers (response-coercers coercion responses opts)
|
(let [coercers (response-coercers coercion responses opts)
|
||||||
coerced (coerce-response coercers request response)]
|
coerced (coerce-response coercers request response)]
|
||||||
(handler request #(respond (coerce-response coercers request %))))
|
(handler request #(respond (coerce-response coercers request %))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue