Timeline for How does a REST API fit for a command/action based domain?
Current License: CC BY-SA 3.0
23 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 11, 2021 at 12:03 | comment | added | Mark Seemann | @Maggyero I must admit that re-reading this entire page confuses me. I remember the question as different from what's there, but no edit history is visible. It may be my memory that fails me, but based on what's on display, I find my own answer incongruent with the question... I'm not sure it's helpful to keep barking up this tree. | |
Jun 11, 2021 at 9:49 | comment | added | Géry Ogam | Mark, what do you think of Cormac Mulhall’s answer? I disagree with it and gave my thoughts in comments, but I would like to have your point of view as I feel it is a fundamental aspect to understand. | |
May 17, 2021 at 22:45 | comment | added | Géry Ogam | Thanks for the recommendation and the informative article. I have just realized that Mark Nottingham published RFC 8288: Web Linking which generalizes RFC 4287: Atom and HTML linking to any formats. | |
May 17, 2021 at 17:03 | comment | added | Mark Seemann |
@Maggyero By default, I use href and rel as originally defined by ATOM. Again, I just went with Subbu Allamaraju's recommendations. Here's an example: blog.ploeh.dk/2020/10/26/fit-urls
|
|
May 17, 2021 at 15:50 | comment | added | Géry Ogam | What hypermedia format do you suggest? Mike Kelly’s JSON Hypertext Application Language? Mark Nottingham’s HTTP Link Hints? And how do we assign semantics to link types for a Web application? | |
May 17, 2021 at 13:01 | comment | added | Géry Ogam |
‘Controller resources’ I really like that name as it makes it explicit that instead of the client controlling resources’ states with the CRUD HTTP methods GET (read), PUT (create and update) and DELETE (delete)—direct control—, the client delegates the control of resources’ states to a controller resource with the HTTP method POST —indirect control. In other words, low-level state management is replaced with high-level state management, i.e. the abstraction level is raised. Alan Kay wrote on this topic.
|
|
May 17, 2021 at 5:40 | comment | added | Mark Seemann |
@Maggyero You can subject resources to different actions via HTTP verbs. The intent behind a GET request is (hopefully) distinct from the intent behind a DELETE request. Usually, in REST, that's sufficient to distinguish between intent. The OP is a little special because it asks how to distinguish between two kinds of intent that don't easily map to two distinct HTTP verbs, which is why it's necessary to model the two distinct intents as two distinguishable resources. The RESTful Web Services Cookbook calls these Controller resources.
|
|
May 16, 2021 at 23:13 | comment | added | Géry Ogam | Mark, you said: ‘They're not RESTful because they use the message body to communicate intent; that's clearly RPC. If you used links to arrive at those resources, then why would you need to communicate intent through the body?’ Do you mean that resources should follow the single responsibility principle in programming, i.e. one resource = one intent? | |
Jan 17, 2017 at 11:05 | vote | accept | leifbattermann | ||
Dec 23, 2016 at 16:29 | comment | added | Cormac Mulhall | This answer sort of implies that URLs are links to follow to carry out an action (if you want to shut down the service follow this URL, if you want to power off the service follow this URL). That isn't RESTful. URLs represent resources, not actions to carry out on resources. The actions are defined in the HTTP spec | |
Dec 22, 2016 at 14:34 | comment | added | guillaume31 | Yes, I'll add an answer to be more specific | |
Dec 22, 2016 at 14:33 | comment | added | leifbattermann | @guillaume31 Do you mean to specify it in the content-type header? | |
Dec 22, 2016 at 14:19 | comment | added | guillaume31 | Well, shutting down and powering off result in the same terminal state, right? Why not use the same verb for both? The media type could distinguish between the two. | |
Dec 22, 2016 at 14:13 | comment | added | leifbattermann | @guillaume31 I see, yes, that's true. Anyway shutting down might fail and then you should be able to power off, as well. | |
Dec 22, 2016 at 14:09 | comment | added | guillaume31 | The resource doesn't have to reflect an VM atemporally, it can represent an execution instance of it. | |
Dec 22, 2016 at 14:07 | comment | added | leifbattermann |
@guillaume31 DELETE seems strange to me because after shutting down the vm will still exist, only in state "power off" (or sth. like that).
|
|
Dec 22, 2016 at 14:05 | comment | added | guillaume31 |
DELETE seems to me like a more appropriate, idempotent verb to shut down a VM
|
|
Dec 22, 2016 at 14:05 | comment | added | leifbattermann | So this: infoq.com/articles/rest-api-on-cqrs according to your answer is not a good design because it exposes the CQRS as a top level architecture, correct? Additionally no hypermedia controls, so at most it's REST level 2. The command type is specified via the content type header. This seems odd to me. What's your opinion? | |
Dec 22, 2016 at 14:03 | comment | added | Mark Seemann | @leifbattermann I suppose in this (degenerate) case you could also use PUT... | |
Dec 22, 2016 at 14:01 | comment | added | leifbattermann | That makes sense. Why do you suggest a POST? Isn't the action idempotent? In any case, how do you tell your client which HTTP method to use? | |
Dec 22, 2016 at 13:25 | comment | added | Mark Seemann | @leifbattermann They're not RESTful because they use the message body to communicate intent; that's clearly RPC. If you used links to arrive at those resources, then why would you need to communicate intent through the body? | |
Dec 22, 2016 at 12:52 | comment | added | leifbattermann | Do you mean that the first examples are both not RESTful because they don't use hypermedia controls? But I didn't even post any responses, only the request URLs and bodies. | |
Dec 22, 2016 at 12:31 | history | answered | Mark Seemann | CC BY-SA 3.0 |