可能重复:结果 Rails 3自定义路由需要多个ID作为参数
据我了解,一个良好的休息网址获取资源是这样的:
From what I understand, a good REST URL for getting a resource would look like this:
/resource/{id}我的问题是,我经常需要在同时得到资源的大量 并不愿意做出的单独的HTTP呼叫作为其中的每一个。
有一个整洁的URL设计,将迎合了或者这只是不适合REST API?
Is there a neat URL design that would cater for that or is this just not suitable for a REST API?
推荐答案根据您的回应,回答你的问题是创建一个包含一套新的信息资源。例如。
Based on your response, the answer to your question is to create a new resource that contains that single set of information. e.g.
GET /Customer/1212/RecentPurchases创建具有许多标识符在一个网址限制高速缓存的优点和增加了不必要的复杂性服务器和客户端的复合网址。当您加载一个网页,有一堆图形,你看不到
Creating composite urls that have many identifiers in a single url limits the benefits of caches and adds unnecessary complexity to the server and client. When you load a web page that has a bunch of graphics, you don't see
GET /MyPage/image1.jpg;image2.jpg;image3.jpg这仅仅是不值得冒这个险。
It just isn't worth the hassle.
更多推荐
REST URL设计
发布评论