REST URL设计

编程入门 行业动态 更新时间:2024-10-26 16:31:35
本文介绍了REST URL设计 - 在一个HTTP调用多个资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可能重复:结果  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设计

本文发布于:2023-10-29 12:59:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539757.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:REST   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!