RESTful URL for “Activate”

后端 未结 3 1289
谎友^
谎友^ 2021-02-06 02:34

I have a resource (project) which can be activated and deactivated.
What\'s the most RESTful URL endpoint for this purpose?

Right now I\'m thinking abou

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 03:04

    The most conventional way to do this is via POST to /projects/:id, with parameters indicating whether you want to activate or deactivate or something else (always leave room for something else).

    note that RESTful URLs should refer to things (like projects), not actions. Then the common methods have clear meanings:

    • PUT: create or replace the thing
    • PATCH: set properties of the thing
    • POST: perform an operation on the thing
    • GET: retrieve the thing
    • DELETE: delete the thing

提交回复
热议问题