ngrunwald / ring-middleware-format

Ring middleware for parsing parameters and emitting responses in JSON or other formats
163 stars 49 forks source link

Custom json content types in response? #32

Closed mdaley closed 8 years ago

mdaley commented 9 years ago

Hi,

I've got a service which includes wrap-json-response in its middleware.

I have resources that I want to return different custom json content types and for example, it would be great if I could just say:

{:status 200 :content-type "application/vnd.mixradio.something+json" :body {:a "a" :b "b"}}

and get a response of the specified content type rather than just application/json; charset=utf-8.

However I don't think this is possible with the way that wrap-json-response works at the moment. Is there a way of doing this or a way that you can see if could be done? If code changes is required, I'm quite willing to create and test a Pull Request given a few hints...

Deraen commented 9 years ago

I'm working on refactor which at least makes to define new formatters. After refactoring is done I'll make sure it's possible to implement this in some way.

Deraen commented 8 years ago

I added a test which should give a hint how to implement this. The API is not very pretty but it should be possible to create json encoder with custom content-type using existing functions.