This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-06
Channels
- # adventofcode (71)
- # aleph (1)
- # announcements (6)
- # aws (1)
- # babashka (27)
- # beginners (60)
- # biff (7)
- # calva (3)
- # clj-kondo (3)
- # clj-yaml (1)
- # clojure (60)
- # clojure-europe (43)
- # clojure-nl (3)
- # clojure-norway (75)
- # clojurescript (16)
- # code-reviews (7)
- # css (4)
- # cursive (47)
- # datascript (4)
- # events (5)
- # fulcro (37)
- # gratitude (5)
- # hyperfiddle (4)
- # introduce-yourself (4)
- # joyride (23)
- # juxt (4)
- # malli (4)
- # membrane (64)
- # nbb (8)
- # off-topic (12)
- # other-languages (6)
- # pathom (6)
- # polylith (9)
- # random (3)
- # rdf (66)
- # reitit (3)
- # releases (2)
- # shadow-cljs (18)
- # tree-sitter (10)
I'm trying to figure out if I can specify a reitit route that takes a vector as query arguments, i.e., :parameters {:query (l/schema {:namespaces [:vector string?]})}
, which is called like route?namespaces=foo&namespaces=bar
and [:parameters :namespaces]
would be ["foo" "bar"]
But I can't get it to work, 400
error.
I found this https://github.com/metosin/reitit/issues/298#issuecomment-1161945435 and tried to add it to my muntaaja coercion but to no avail. the singleton->vector
function is never called
(defn singleton->vector
[x]
(println "BOOM!" x)
(if (vector? x) x [x]))
(def custom-string-type-decoders
(assoc (malli.transform/-string-decoders) :vector singleton->vector))
(def custom-string-transformer
(malli.transform/transformer
{:name :string
:decoders custom-string-type-decoders
:encoders malli.transform/-string-decoders}))
(def muuntaja-instance
(-> muuntaja/default-options
(update-in [:formats "application/transit+json"] assoc
:encoder-opts {:handlers transit-encoder-handlers}
:decoder-opts {:handlers transit-decoder-handlers})
(assoc-in [:transformers :string :default] custom-string-transformer)
(muuntaja/create)))