【发布时间】:2017-06-01 21:08:56
【问题描述】:
TutorialsPoint 在 RESTful 设计的上下文中定义了以下方法:
URI HTTP Body Result
-----------------------------------------------------------------
listUsers GET empty Show list of all the users
addUser POST JSON string Add details of new user
deleteUser DELETE JSON string Delete an existing user
:id GET empty Show details of a user
我认为这是误导,因为它不是 RESTful。
RESTful 设计如下:
URI HTTP Body Result
----------------------------------------------------------------
users GET empty Show list of all the users
users POST JSON string Add details of new user
users DELETE empty Delete an existing user
users/:id GET empty Show details of a user
我对 RESTful 的理解正确吗?
不管 RESTful 的定义如何,在我看来,TutorialsPoint 的设计是错误的,因为 URL 中的deleteUser 复制了已经作为DELETE HTTP 动作传递的信息,这违反了Once And Only Once 的普遍原则。
【问题讨论】: