Sunil Shah created MESOS-2257:
---------------------------------

             Summary: Set Mesos specific content type with version for HTTP 
endpoints
                 Key: MESOS-2257
                 URL: https://issues.apache.org/jira/browse/MESOS-2257
             Project: Mesos
          Issue Type: Improvement
            Reporter: Sunil Shah
            Priority: Minor


As a consumer of the Mesos HTTP API, it is necessary for us to determine the 
current version of Mesos so that we can parse the JSON documents returned 
correctly (since they change from version to version). 

Currently we're doing this by fetching state.json, parsing it and pulling out 
the version field. A more idiomatic way to do this would be to filter on the 
content-type in the header itself.

To give a more concrete example, currently the JSON documents returned by the 
HTTP API return the following headers:
{code}
HTTP/1.1 200 OK
Date: Fri, 23 Jan 2015 21:31:37 GMT
Content-Length: 9352
Content-Type: application/json
{code}

Something like the following (e.g. for master/state.json) would be easy to 
switch upon:
{code}
HTTP/1.1 200 OK
Date: Fri, 23 Jan 2015 21:31:37 GMT
Content-Length: 9352
Content-Type: application/vnd.mesos.master.state.v0.20.1+json; charset=utf-8
{code}

The vnd prefix is typically used for vendor specific file types (see: 
http://en.wikipedia.org/wiki/Internet_media_type#Prefix_vnd). Charset=utf-8 is 
required for JSON documents and is currently being omitted.

This content-type would change for each document type, for example:
{code}
application/vnd.mesos.master.state.v0.20.1+json; charset=utf-8
application/vnd.mesos.master.stats.v0.20.1+json; charset=utf-8
application/vnd.mesos.slave.state.v0.20.1+json; charset=utf-8
application/vnd.mesos.slave.stats.v0.20.1+json; charset=utf-8
{code}

Alternatively, the version could be appended as an extra field:
{code}
application/vnd.mesos.master.state+json; charset=utf-8; version=v0.20.1
application/vnd.mesos.master.stats+json; charset=utf-8; version=v0.20.1
application/vnd.mesos.slave.state+json; charset=utf-8; version=v0.20.1
application/vnd.mesos.slave.stats+json; charset=utf-8; version=v0.20.1
{code}

Thanks!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to