这是一个糟糕的 REST URL 吗? [英] Is this a bad REST URL?

查看:32
本文介绍了这是一个糟糕的 REST URL 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚阅读了有关 REST URL 的内容,并看到了以下示例:

I've just been reading about REST URLs and seen the following example:

/API/User/GetUser

/API/User/GetUser

现在,如果使用动词 GET 通过 HTTP 访问它,这不是一个糟糕的 URL,因为它描述了 URL 中的操作 (GET)?

Now if this is accessed over HTTP with a verb GET isn't this a bad URL becuase it describes the action (GET) in the URL?

推荐答案

没有 REST URL 这样的东西.事实上,REST URL 这个词几乎是一个矛盾的说法.超媒体作为应用程序状态的引擎 约束保证 URL 无关紧要:无论如何,您只会访问服务器提供给您的链接.您永远不会在任何地方看到、阅读或键入 URI.(就像浏览网页一样:您不需要查看链接的 URL,阅读它,记住它,然后将其输入地址栏中;您只需单击它,而不必关心它实际说的是什么.)

There is no such thing as a REST URL. In fact, the word REST URL is pretty much an oxymoron. The Hypermedia As The Engine Of Application State Constraint guarantees that URLs are irrelevant: you are only ever following links presented to you by the server, anyway. You never see, read or type a URI anywhere. (Just like browsing the web: you don't look at the URL of a link, read it, memorize it and then type it into the address bar; you just click on it and don't care what it actually says.)

术语 REST URL 意味着您关心 REST 架构中的 URL.但是,如果您关心 REST 架构中的 URL,那么您就不是 RESTful.因此,REST URL 是矛盾的.

The term REST URL implies that you care about your URLs in your REST architecture. However, if you care about your URLs in your REST architecture, you are not RESTful. Therefore, REST URL is an oxymoron.

[注意:正确的 URI 设计对于 URI 的 URI-ness 非常非常重要,尤其是 I 部分.此外,漂亮 URL 有很多很好的可用性理由.但这两者都与 REST 没有任何关系.]

[Note: Proper URI design is very important for the URI-ness of a URI, especially the I part. Also, there's plenty of good usability reasons for pretty URLs. But both of these have nothing whatsoever to do with REST.]

这篇关于这是一个糟糕的 REST URL 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆