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.
i implement new resource, on different url like:
content/articles/web/{id}
, move old 1content/article/app/{id}
i specify in documentation of resource, client should specify specific
request header
maybeaccept
header webservice determine representation of article return.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
Post a Comment