diff --git a/ring-core/src/ring/middleware/nested_params.clj b/ring-core/src/ring/middleware/nested_params.clj index 7a6abb4b..830331a8 100644 --- a/ring-core/src/ring/middleware/nested_params.clj +++ b/ring-core/src/ring/middleware/nested_params.clj @@ -58,9 +58,11 @@ See: wrap-nested-params." {:arglists '([request] [request options]) :added "1.2"} - [request & [opts]] + [{:keys [params] :as request} & [opts]] (let [parse (:key-parser opts parse-nested-keys)] - (update-in request [:params] nest-params parse))) + (if (or (empty? params) (-> params meta :nested-params)) + request + (assoc request :params ^:nested-params (nest-params params parse))))) (defn wrap-nested-params "Middleware to converts a flat map of parameters into a nested map. diff --git a/ring-core/src/ring/middleware/params.clj b/ring-core/src/ring/middleware/params.clj index c1ed351e..09588a3e 100644 --- a/ring-core/src/ring/middleware/params.clj +++ b/ring-core/src/ring/middleware/params.clj @@ -29,7 +29,7 @@ {:form-params {}, :params {}}))) (defn params-request - "Adds parameters from the query string and the request body to the request + "Adds parameters from the request body and the query string to the request map. See: wrap-params." {:arglists '([request] [request options]) :added "1.2"} @@ -51,7 +51,7 @@ :query-params - a map of parameters from the query string :form-params - a map of parameters from the body - :params - a merged map of all types of parameter + :params - a merged map of all types of parameter, query-params last Accepts the following options: