This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-14
Channels
- # admin-announcements (21)
- # aws (5)
- # boot (41)
- # cider (76)
- # cljs-dev (15)
- # clojure (251)
- # clojure-brasil (25)
- # clojure-dev (16)
- # clojure-japan (8)
- # clojure-nl (1)
- # clojure-russia (110)
- # clojure-uk (7)
- # clojurescript (168)
- # clojurewerkz (1)
- # cursive (10)
- # datomic (45)
- # devcards (50)
- # emacs (5)
- # hoplon (6)
- # instaparse (6)
- # ldnclj (73)
- # lein-figwheel (4)
- # leiningen (6)
- # liberator (7)
- # luminus (2)
- # off-topic (19)
- # om (80)
- # onyx (2)
- # re-frame (11)
- # testing (12)
@jonas: Just signed in here to ask a similar question.... I'd basically like to find a way to return structured JSON error objects from all the handlers if the accept header is JSON... Would be nice to also content-neg them for json/edn and HTML.
Some specific paths will generate specific errors e.g. a 422 might return a JSON error map saying which form fields had errors... but I'd also like to upcast all the other errors to be JSON objects... e.g. instead of just returning a 410
"Resource Gone"
I'd like to convert that error to something like:
{'error-message': "Resource Gone"}
if JSON is requested
as-response
looks like it might be useful
This is a know problem in liberator right now, there’s no media-type in the context for handlers before content negotitaion. I will post a work around later, unfortunately I need to pop out for an appointment now.
@ordnungswidrig: Thanks, I’m looking forward to the workaround.
@rickmoynihan: I will take a look at as-response. Thanks for the pointer
Basically what I’m using is a function for :as-response that adds a fallback media type to the context and passes on to the default as-reponse method: