简体   繁体   English

宁静的服务,通过扩展输出类型

[英]Restful services, output type by extensions

We are developing "Restful" things. 我们正在开发“有趣的”事物。 We use Jersey on OSGI (Adobe's CRX, which packs Apache Felix). 我们在OSGI(Adobe的CRX,其中包含Apache Felix)上使用Jersey。 The API Spec comes up with some thing dealing with conflicting restful requests, something like if the client sends the header Accept: application/json and the request url is http:// * /myresource.xml, we have to send json back (Jersey will send xml back). API规范提出了一些处理冲突的静态请求的方法,例如,如果客户端发送标头Accept:application / json且请求url为http:// * /myresource.xml,我们必须将json发送回去(Jersey将发回xml)。

Also it seems the main person (very high rank technical and knowledgeable person) said we shouldn't use the extension such as .xml or .json for a search (non-resource), ie, it is against the 'principle' to do something like "http://myrest/search.json?q=abc". 同样,主要人员(非常高级的技术和知识渊博的人)说,我们不应该使用.xml或.json这样的扩展名进行搜索(非资源),即,这样做违反了“原则”类似于“ http://myrest/search.json?q = abc”。 Instead, we should do some thing like "http:// * /search?output=json&q=abc" ( Implementing such a spec just makes our lives hard since manipulating what a framework (Jersey) provides is not fun). 相反,我们应该做一些类似“ http:// * / search?output = json&q = abc”的事情(实现这样的规范只会使我们的生活变得艰难,因为操作框架(Jersey)提供的内容并不有趣)。

What is your opinion? 你有什么意见?

Why do you use a special URL at all? 为什么根本使用特殊的URL? If the client sends the Accept: application/json he should get json. 如果客户端发送Accept:application / json,他应该得到json。 So how about using just http://myrest/search?q=abc 那么,仅使用http://myrest/search?q=abc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM