Survey state transition diagram |
Method | URL | Details |
---|---|---|
GET | /surveys/:id/state | Get the current state of a survey |
PUT | /surveys/:id/state | Set the state of a survey |
The PUT request can have the state to set in the request body. The response can be 200 with the set result. The response can also be 4xx, if the client has erred. The error can be 403 forbidden, 404 survey not found, or 409 conflict if the state to set is not supported.
I am surprised to see that POST was used to set survey state in Google's survey API. The interfaces are:
Method | URL | Details |
---|---|---|
POST | /surveys/:id/start | set the survey to be active |
POST | /surveys/:id/stop | set the survey to be idle |
This design has two problems compared to the previous design:
- /surveys/:id/start and /surveys/:id/stop are not resources; and
- POST is not idempotent, but PUT is.
No comments:
Post a Comment