what is the purpose of error-interceptor-chain
? Can’t find docs on this
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
sounds good 🙂 thanks for confirming
hello everyone! can anyone give me a comparison between yada and liberator?