innoq / statuses

statuses
Apache License 2.0
13 stars 14 forks source link

support content negotiation via Accept header #171

Open FND opened 9 years ago

FND commented 9 years ago

currently requesting an alternative representation requires a query parameter (e.g. ?format=json) - the same should be possible with an Accept header

I'd tried looking into this, but the current implementation is too primitive, providing insufficient infrastructure for a Clojure ignoramus like myself to get started: https://github.com/innoq/statuses/blob/53d3186/src/statuses/routes.clj#L12 https://github.com/innoq/statuses/blob/53d3186/src/statuses/routes.clj#L33

mvitz commented 9 years ago

routes.clj only contains the URI route patterns and functions for generating links inside statuses. The routes statuses responds to can be found here. The last argument is the function which is called when a route is hit. E.g. hitting /statuses/info results in info being called.

A first starting point would be to check there for the Accept header and render the content in the matching format.

Hope this helps.