用于“激活”的RESTful URL [英] RESTful URL for "Activate"

查看:157
本文介绍了用于“激活”的RESTful URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以激活和停用的资源(项目)。

为此目的,最具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屋!

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