1
我一直在挖掘這裏關於寧靜關係的幾個問題,但還沒有找到什麼即時通訊。另一個其他API關係
考慮這種情況下
GET /api/users(?include=custom_fields) - returns an array of users, optionally including relations as nested properties
GET /api/users/1(?include=custom_fields) - returns a single user object
POST /api/users - creates a new user (if the request includes an array of "custom_fields" these are created and linked)
PUT /api/users/1 - replaces user entity with supplied payload
PATCH /api/users/1 - updates the user properties provided
DELETE /api/users/1 - deletes
GET /api/users/1/custom_fields - gets all users custom_fields
PUT /api/users/1/custom_fields - deletes all existing custom_fields and creates ones provided
PATCH /api/users/1/custom_fields - appends if not exists, or creates new custom fields for this user
DELETE /api/users/1/custom_fields - deletes all custom fields for user
DELETE /api/users/1/custom_fields/{id} - deletes custom field for use by id.
這一切對我來說很有意義,並正在按照預期,但即時通訊目前正在實施在我的管理區域「用戶編輯」屏幕上,這表明用戶對象和自定義字段。
現在唯一的RESTful方式我可以看到保存這個形式是:
補丁/ API /用戶/ {ID}
保存用戶。當多數民衆贊成在做,
PUT到/ API /用戶/ {ID}/custom_fields
更新的自定義字段。
不理想,但會工作,但展望未來,我知道我肯定會有其他相關資源,如用戶角色,電子郵件等
這並沒有改變它只是意味着很多多個端點的情況。
這件事對我來說很陌生。簡單地保存用戶即時消息不得不向至少兩個端點發出請求。
如果沒有兩個不同的要求,你會如何處理這個問題?