This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-23
Channels
- # announcements (7)
- # babashka (40)
- # babashka-sci-dev (74)
- # beginners (74)
- # calva (31)
- # cider (11)
- # clj-kondo (22)
- # cljs-dev (1)
- # cljsrn (1)
- # clojure (70)
- # clojure-brasil (3)
- # clojure-dev (12)
- # clojure-europe (39)
- # clojure-nl (2)
- # clojure-norway (15)
- # clojure-uk (9)
- # clojurescript (69)
- # community-development (2)
- # conjure (1)
- # core-async (3)
- # cursive (1)
- # data-science (1)
- # datalevin (13)
- # datomic (17)
- # emacs (42)
- # events (1)
- # fulcro (16)
- # graphql (9)
- # helix (1)
- # holy-lambda (14)
- # honeysql (2)
- # hugsql (3)
- # hyperfiddle (5)
- # kaocha (10)
- # lsp (41)
- # luminus (5)
- # malli (7)
- # meander (3)
- # membrane (47)
- # off-topic (23)
- # podcasts (2)
- # polylith (34)
- # rdf (4)
- # re-frame (2)
- # releases (2)
- # remote-jobs (1)
- # ring (16)
- # shadow-cljs (111)
- # spacemacs (6)
- # test-check (2)
- # tools-deps (19)
is there some middleware to normalize query/body parameter names e.g. someParam -> some_param
?
Compojure at the moment, but I’m actually thinking about switching to reitit so you’re solution is potentially useful 🙂
(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 -> clojure
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
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 🙂
@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