This commit is contained in:
Juho Teperi 2025-01-22 10:22:58 +02:00
parent 5829e1c656
commit dba8d159cc

View file

@ -78,13 +78,14 @@
;; on the coercion? ;; on the coercion?
;; NOTE: Re-creates coercer on every call, could this be pre-compiled somewhere ;; NOTE: Re-creates coercer on every call, could this be pre-compiled somewhere
;; or memoized? Does it matter much? ;; or memoized? Does it matter much?
;; TODO: query-coercer could be compiled in reitit.frontend/router, same as request coercers.
(str "?" (let [coercion (-> match :data :coercion) (str "?" (let [coercion (-> match :data :coercion)
schema (when coercion schema (when coercion
(coercion/-compile-model coercion (-> match :data :parameters :query) nil)) (coercion/-compile-model coercion (-> match :data :parameters :query) nil))
coercer (when (and schema coercion) coercer (when (and schema coercion)
(coercion/-query-string-coercer coercion schema)) (coercion/-query-string-coercer coercion schema))
query-params (or (when coercer query-params (if coercer
(coercer query-params :default)) (coercer query-params :default)
query-params)] query-params)]
;; Default encoding for values will handle values that aren't encoded using coercer ;; Default encoding for values will handle values that aren't encoded using coercer
(impl/query-string query-params))))))) (impl/query-string query-params)))))))