Is this a bad REST URL?

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

/API/User/GetUser

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?


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.)

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.

[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.]


It's more of a convention, than a hard rule, but I would rather see something like /API/User/7123 . The GET/POST/etc describes the action verb, so also putting it in the url makes it redundant. And in this situation there's no reason not to follow good proven practices.

Here's some good stuff: Understanding REST: Verbs, error codes, and authentication


GET /API/User/7123 to get user 7123.

POST to /API/User to create a user.

PUT to /API/User/7123 to update user 7213.

DELETE to /API/User/7123 to delete user 7213.

As others have said, REST is not a hard and fast rule, more an approach.

Use the http verbs to achive actions based upon a resource location (URL).

But mostly do what is most appropriate for your needs.

EDIT: Remember though, the verbs are about defining the intended semantics of the communication and not the server implementation.

EDIT2: This is my favourite answer regarding REST.

链接地址: http://www.djcxy.com/p/45352.html

上一篇: Web应用程序中的Jboss Drools

下一篇: 这是一个糟糕的REST网址吗?