liberator

2015-10-14T11:18:39.000005Z

@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

2015-10-14T11:19:58.000008Z

as-response looks like it might be useful

ordnungswidrig 2015-10-14T17:12:37.000009Z

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.

jonas 2015-10-14T17:18:31.000010Z

@ordnungswidrig: Thanks, I’m looking forward to the workaround.

jonas 2015-10-14T17:18:56.000011Z

@rickmoynihan: I will take a look at as-response. Thanks for the pointer

2015-10-14T17:28:53.000012Z

@ordnungswidrig: thanks :simple_smile:

ordnungswidrig 2015-10-14T21:05:47.000013Z

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: