用于“激活”的RESTful URL [英] RESTful URL for "Activate"
问题描述
我有一个可以激活和停用的资源(项目
)。
为此目的,最具RESTful的URL端点是什么?
I have a resource (project
) which can be activated and deactivated.
What's the most RESTful URL endpoint for this purpose?
现在我正在考虑 / projects /:id / activate
和 / projects /: id / deactivate
,但我认为这不是非常RESTful。
另外,我不确定使用什么HTTP方法。
Right now I'm thinking about /projects/:id/activate
and /projects/:id/deactivate
, but I don't think that's very RESTful.
In addition, I'm not certain what HTTP method to use.
你能提供一些指示吗?
谢谢!
Can you provide some pointers?
Thanks!
推荐答案
你可以发送您的请求只是 projects / {id}
并使用 PATCH
(当您更新现有对象时)动词,例如
Your can send your requests just to projects/{id}
and use PATCH
(as you're updating existing object) verb, e.g.
PATCH /projects/123
[
{ "op": "activate|deactivate", ... }
]
了解更多: REST API - 使用现实生活中的PUT与PATCH
这篇关于用于“激活”的RESTful URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!