diff --git a/CHANGELOG.md b/CHANGELOG.md index 4064cb67..446d42e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## UNRELEASED +## `reitit-core` + +* **BREAKING**: the router option key to extract body format has been renamed: `:extract-request-format` => `:reitit.coercion/extract-request-format` + * should only concern you if you are not using [Muuntaja](https://github.com/metosin/muuntaja). + ## `reitit-swagger-ui` * **BREAKING**: pass swagger-ui `:config` as-is (instead of mixed-casing keys) to swagger-ui, fixes [#109](https://github.com/metosin/reitit/issues/109): diff --git a/modules/reitit-core/src/reitit/coercion.cljc b/modules/reitit-core/src/reitit/coercion.cljc index 91a02231..04515d51 100644 --- a/modules/reitit-core/src/reitit/coercion.cljc +++ b/modules/reitit-core/src/reitit/coercion.cljc @@ -34,7 +34,7 @@ (defrecord ParameterCoercion [in style keywordize? open?]) -(def ^:no-doc defaut-parameter-coercion +(def ^:no-doc default-parameter-coercion {:query (->ParameterCoercion :query-params :string true true) :body (->ParameterCoercion :body-params :body false false) :form (->ParameterCoercion :form-params :string true true) @@ -70,10 +70,11 @@ (-> request :muuntaja/request :format)) ;; TODO: support faster key walking, walk/keywordize-keys is quite slow... -(defn request-coercer [coercion type model {:keys [extract-request-format] - :or {extract-request-format extract-request-format-default}}] +(defn request-coercer [coercion type model {:keys [::extract-request-format ::parameter-coercion] + :or {extract-request-format extract-request-format-default + parameter-coercion default-parameter-coercion}}] (if coercion - (let [{:keys [keywordize? open? in style]} (defaut-parameter-coercion type) + (let [{:keys [keywordize? open? in style]} (parameter-coercion type) transform (comp (if keywordize? walk/keywordize-keys identity) in) model (if open? (-open-model coercion model) model) coercer (-request-coercer coercion style model)]