REST Content-Type: Should it be based on extension

2019-01-06 10:11发布

Should the representation(html, xml, json) returned by a RESTful web service be determined by the url or by the Accept HTTP header?

标签: rest
7条回答
别忘想泡老子
2楼-- · 2019-01-06 10:46

Since very many RESTful URLs do not have an extension, you should/must base on Content-Type

edit: I don't mean this to sound as harsh as it does, more that you're going to have to pay attention to content-type and won't always be able to refer to extension

查看更多
登录 后发表回答