This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-01
Channels
- # aws (2)
- # aws-lambda (18)
- # beginners (68)
- # boot (6)
- # cider (2)
- # clara (2)
- # clojars (27)
- # clojure (68)
- # clojure-austin (5)
- # clojure-berlin (6)
- # clojure-dev (28)
- # clojure-greece (7)
- # clojure-italy (46)
- # clojure-japan (3)
- # clojure-nl (1)
- # clojure-russia (8)
- # clojure-sg (1)
- # clojure-spec (17)
- # clojure-uk (86)
- # clojurescript (82)
- # community-development (2)
- # cursive (18)
- # datomic (11)
- # duct (5)
- # fulcro (254)
- # garden (2)
- # graphql (6)
- # hoplon (19)
- # instaparse (4)
- # kekkonen (2)
- # leiningen (4)
- # luminus (3)
- # lumo (9)
- # off-topic (28)
- # om (7)
- # onyx (38)
- # other-languages (27)
- # portkey (7)
- # protorepl (1)
- # re-frame (56)
- # reagent (64)
- # ring (14)
- # ring-swagger (7)
- # shadow-cljs (255)
- # sql (2)
- # vim (11)
- # yada (10)
The way yada uses Records (and maybe all uses of Records) seems magical to me. When calling a response fn, it wraps the ctx
in a Response
record, and if you merge the correct way (or assoc), you get to control status code, etc. If you don’t merge the correct way, you get a hashmap as the body.
Is this idiomatic Clojure?
It's a tradeoff. The problem in Liberator was in determining if the user was returning a map or actually a Ring response. Namespaced keys might be a better approach.
I agree, the approach in yada isn't idiomatic
But records are useful
They have Rich's seal of approval 😊
(defrecord Foo [])
(instance? Foo (merge (Foo.) {})) ;; => true
(instance? Foo (merge {} (Foo.))) ;; => false
@malcolmsparks Haha, yes they have. Since 1.2 as I read it. Maybe he’s changed his mind since then 😉