RESTful URL for “Activate”

后端 未结 3 1296
谎友^
谎友^ 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:09

    I know I am a bit late but maybe this might be useful for others.

    You can create a noun from your operation and use it as sub-resource: activate -> activation

    Now you can use POST and DELETE on this sub-resource.

    For example:

    POST /projects/:id/activation       <-- activate project
    DELETE /projects/:id/activation     <-- deleting the activation = deactivate
    

    This pattern can work quite well for operations that toggle between on/off state of something.

提交回复
热议问题