This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-19
Channels
- # announcements (6)
- # aws (10)
- # beginners (73)
- # bristol-clojurians (2)
- # calva (9)
- # cider (25)
- # clj-kondo (7)
- # clojure (160)
- # clojure-dev (2)
- # clojure-europe (63)
- # clojure-italy (7)
- # clojure-nl (10)
- # clojure-uk (76)
- # clojuredesign-podcast (6)
- # clojurescript (63)
- # cursive (6)
- # data-science (3)
- # datomic (26)
- # duct (59)
- # emacs (1)
- # fulcro (12)
- # graalvm (17)
- # hoplon (23)
- # jobs-discuss (2)
- # kaocha (6)
- # meander (7)
- # off-topic (3)
- # pathom (2)
- # rdf (68)
- # re-frame (12)
- # reagent (20)
- # reitit (5)
- # ring (3)
- # ring-swagger (1)
- # shadow-cljs (14)
- # spacemacs (10)
- # sql (3)
- # tools-deps (30)
- # yada (9)
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.