Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A few points; <br></p> <h3>The domain of the service interface != the implementation domain</h3> <p>The resources exposed by your service do not have to be directly implemented as objects in your code. The (service) interface is not the implementation.</p> <p><br></p> <h3> Put & Post require all of the external state </h3> <p>You must provide all of the resource state when doing your updates (you said that you only provide the changes - that's a PATCH not a PUT).</p> <p><br></p> <h3> Modelling state changes via collection resources </h3> <p>Sometimes it's best to model a state change as a collection resource. In your example, you really need to consider either a 'Review' resource with an associated 'Review-queue' <b>or</b> add a 'Needs review' attribute to the widget. </p> <p><b>Approach 1. A container for the 'review-queue'</b></p> <p>Having the 'Review' object would make it easy to list widgets for review, assign resources for review etc </p> <p>GET /review-queue -- to list the widgets which need review</p> <p>POST /review-queue -- create a new review entry (listing just the id, name of the widget and a url back to the widgets)</p> <p>DELETE /review-queue/X -- delete from the queue when the widget has been reviewed</p> <p>I'd use this approach if there was significant behaviour associated with the 'review-queue' e.g. permissions associated with adding a widget for review, multiple review queues etc <br></p> <p><b>Approach 2. 'Needs-review' attribute</b></p> <p>You may decide that a separate resource is over-kill for your needs. You can model the basic functionality with POST, PUT and GET.</p> <p>When a widget is created, it's state include a s 'needs-review' attribute which is set to False. Obviously you need all of the external state in the POST</p> <p>When a widget needs review, GET it and PUT it back with the 'needs-review' updated. Again, <i>you need all of the external state</i> in the PUT</p> <p>When listing the widgets for review use</p> <p>GET /widgets/?needs_review=true</p> <p><br></p> <h3>Poor old RPC</h3> <p><i>You mention RPC in your last paragraph and although it's off-topic, I can't help but comment...</i></p> <p>I think perhaps we're all guilty now of blaming RPC for the ills of the world. The real problem with RPC is that it aimed to make remote function calls transparent to the programmer, hiding failure scenarios and attempting to make a remote call equivalent in the implementation language as a standard function call. As an old CORBA (which suffered from the same problem) programmer, I can appreciate how REST corrects that failing. </p> <p><br> <b>Other points from your post</b></p> <p>You can't determine which method to call without examining the new state and comparing it to the existing state.</p> <p>You should validate the new state before doing anything else, passing any errors back to the submitter.</p> <p>From you're last paragraph, I think you know this already - sorry.</p> <p>Chris</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload