is there some middleware to normalize query/body parameter names e.g. someParam -> some_param ?
which router are you using? If you're using reitit I have a solution for that
Compojure at the moment, but Iβm actually thinking about switching to reitit so youβre solution is potentially useful π
This is what I do:
(def ^:private custom-serialization
(m/create
(-> m/default-options
(assoc-in [:formats "application/json" :encoder-opts] {:encode-key-fn (comp csk/->snake_case name)}) ;; clojure -> json
(assoc-in [:formats "application/json" :decoder-opts] {:decode-key-fn (comp keyword csk/->kebab-case)})))) ;; json -> clojureThen in the configuration/data of reitit:
:muuntaja custom-serialization
works a treat
you can swap out the csk to whatever you need
I also prefer reitit, but your example does not use anything reitit-specific, right? Muuntaja is a standalone library that you can also use as a ring middleware. https://github.com/metosin/muuntaja/blob/master/doc/With-Ring.md
Very true π
But, if he's switching maybe to reitit, at least he knows what I do π
We should probably also point @slack.jcpsantiago to https://github.com/clj-commons/camel-snake-kebab β the csk namespace in your example is just that π
oh yes, good shout. Tis a great library.
@ferdinand @dharrigan thank you both! yeah csk gets me super far already actually, but like I said Iβll move to reitit so @dharriganβs solution is great
np, glad to help π