web services - RESTservice, resource with two different outputs - how would you do it? -


im working on more or less restful webservice, type of content api companys articles. have resource getting content of specific article

http://api.com/content/articles/{id}

will return full set of article data of given article id.

currently control alot of article's business logic becasue serve native-app webservice. means convert tags, links, images , on in body text of article, protocol native-app can understand. same alot of different attributes , data on article, transform , modify original (web) state state native-app understand.

fx. img tags converted normal <img src="http://source.com"/> <img src="inline-image//{imageid}"/> tag, samt goes anchor tags etc.

now have implement resource can return articles data in new representation

i'm puzzled on how best this.

  1. i implement new resource, on different url like: content/articles/web/{id} , move old 1 content/article/app/{id}

  2. i specify in documentation of resource, client should specify specific request header maybe accept header webservice determine representation of article return.

  3. i use original url, , use url parameter .../{id}/?version=app or .../{id}/?version=web

what guys reckon best option? personal preference lean towards option 1, because think easier understand clients of webservice.

regards, martin.

edit:

i have chosen go option 1. helping out , giving pros , cons. :)

i choose #1. if need preserve existing urls add new 1 content/articles/{id}/native or content/native-articles/{id}/. both rest enough.

working paths make content more cacheable both header or param options. using content-type overcomplicates service when both returning json.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -