Fork me on GitHub
#yada
<
2018-10-09
>
nha11:10:02

what is the purpose of error-interceptor-chain? Can’t find docs on this

nha12:10:30

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?

malcolmsparks12:10:54

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

nha14:10:23

sounds good 🙂 thanks for confirming

Andrea Imparato21:10:37

hello everyone! can anyone give me a comparison between yada and liberator?