Ok, here's a fun one that I'm hoping anyone here can help me with:
(require '[ring.middleware.params :refer [wrap-params]])
(require '[ring.mock.request :as mock])
(let [fake-handler (wrap-params identity)
request (mock/request :get "/foo" {:query-params {:x [1 2 3]}})]
(fake-handler request))
The result is:
{:protocol "HTTP/1.1",
:remote-addr "127.0.0.1",
:params {"query-params" "x=1", "x" ["2" "3"]},
:headers {"host" "localhost"},
:server-port 80,
:form-params {},
:query-params {"query-params" "x=1", "x" ["2" "3"]},
:uri "/foo",
:server-name "localhost",
:query-string "query-params=x=1&x=2&x=3",
:scheme :http,
:request-method :get}
I'm a bit stumped as to why the params are decoded as they are. Any insight would be great as well as any tips on the right way to get the original x vector recovered in the params.Figured it out. I am adding the params incorrectly. Should be:
(require '[ring.middleware.params :refer [wrap-params]])
(require '[ring.mock.request :as mock])
(let [fake-handler (wrap-params identity)
request (mock/request :get "/foo" {:x [1 2 3]})]
(fake-handler request))
BTW, ring-mock would be a good topic. For example, I don't see great docs on how to specify form params, body params, etc.
ah interesting
glad you figured it out
testing would be a good topic, indeed