E
E
E_K2016-06-18 04:32:45
PHP
E_K, 2016-06-18 04:32:45

How to correctly organize API using REST and SOLID when partially updating an entity?

It is necessary to ensure that the photo and information about the user is uploaded to the server. Currently, the user information and photo are saved to the server by two different requests (one method = one action) and are processed in the same way on the server. The update action for an entity within the REST framework must be performed using a PUT request. Which option is better to choose:
1. Run the same request for both actions, on the server, depending on the passed parameters passed to the update() method of the controller, call updateInfo() or updatePhoto()
2. Add an action parameter to the request?
3. Create classes on the server to manage file operations and generate queries like /user/4/image/?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-06-18
@E_K

The update action for an entity within the REST framework must be performed using a PUT request.

A user photo could very well be another resource.
Sounds creepy.
Not restful. More like RPC.
users/4/photos or something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question