This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-09
Channels
- # 100-days-of-code (6)
- # announcements (4)
- # atlanta-clojurians (1)
- # aws (1)
- # beginners (65)
- # boot (21)
- # cider (9)
- # cljsrn (3)
- # clojure (186)
- # clojure-android (4)
- # clojure-conj (1)
- # clojure-dev (12)
- # clojure-germany (3)
- # clojure-italy (8)
- # clojure-nl (1)
- # clojure-russia (32)
- # clojure-spec (19)
- # clojure-uk (41)
- # clojurescript (83)
- # core-async (5)
- # cursive (18)
- # datomic (15)
- # emacs (5)
- # events (4)
- # fulcro (7)
- # hyperfiddle (4)
- # leiningen (4)
- # liberator (1)
- # off-topic (65)
- # overtone (4)
- # pedestal (5)
- # perun (1)
- # planck (3)
- # re-frame (1)
- # reagent (3)
- # rum (5)
- # shadow-cljs (8)
- # spacemacs (19)
- # testing (3)
- # tools-deps (4)
- # yada (6)
I have a question:
(yada/response-for
["/hello-response"
(yada/resource
{:id :RESP
:methods
{:get
{:parameters {:query {(s/required-key :p) String}}
:produces #{;;"text/plain"
"application/json"}
:response (fn [ctx] {:data (format "Hello %s!\n" (-> ctx :parameters :query :p))})}}})]
:get "/hello-response"
{:headers {;; I was expecting the "Accept" header
;; to make yada.body/render-error "application/json" being called
;; instead of "text/plain" ?
"Accept" "application/json"}})
;; => {:status 400, :headers {“content-length” “73", “content-type” “text/plain;charset=utf-8"}, :body “\r\n\r\n{:status 400, :errors ([:query {:error {:p missing-required-key}}])}\n”}
;; yada.body/render-error “text/plain” is called
I was expecting “application/json” to be called. What am I doing wrong?The default error handler doesn't offer application/json. The reason is because too many errors were swallowed by cheshire rendering exceptions. You could put in your own error interceptor chain if you need json
hello everyone! can anyone give me a comparison between yada and liberator?
Have you seen these? https://github.com/juxt/yada/blob/master/dev/resources/includes/liberator.md https://juxt.pro/blog/posts/yada-1.html also Malcolm was one of the authors of Liberator: https://github.com/clojure-liberator/liberator/graphs/contributors