实体属性更改的自定义逻辑的RESTful解决方案

What is the best (for lack of a better word) way to implement additional logic for when particular properties on an entity change? For example, a syncing property is changed from false to true. When the client PUTs the resource with the modified field, an HTTP request needs to be sent to a 3rd party API to enable/disable this feature on their end.

The options I can't choose between are:

  1. Custom operation controllers to toggle the property value (e.g. PUT /room/{id}/syncing, DELETE /room/{id}/syncing)
  2. A controller for PUT /room/{id} and to check if the value has changed in the request compared to what exists in the database
  3. An event listener on the onKernelController event, to detect changes to the property on the entity

According to standard your best choice is the second one:

PUT /room/{id}

Inside the body request you will append the value of syncing and in the controller you update the value inside database.

Try PATCH, unlike PUT, this is meant to update just part of the resource. If the resource represents an entity, patch suits the best if you wanna change just one property of the entity.

PATCH /room/{id}

I decided in the end to add an event listener at my data access layer for the entity in question, and perform the additional logic and 3rd party API request onUpdate, onPersist, and onRemove. This seemed like the most appropriate place to add this logic as it will be performed wherever the entity is modified