Closed JornWildt closed 9 years ago
Very good point!
I'd suggest grouping all links under @links
to keep standard hypermedia term of the link in place. Then just add an argument called action
or operation
.
UBER uses action
with four posible values:
By having action or operation there will be no need to support method
directly.
By having action or operation there will be no need to support method directly.
Nah, actions in Mason are different from Uber. A Mason action can for instance be of type "json" (for sending a JSON encoded payload) or "json+files" (for sending multipart content) - both of these can be sent using either POST or PUT, so the method would still be required.
I see, you are talking about additional type
of the @action
which is specific to Mason: any
, json
, json+files
, void
. That is true, actions in UBER and Mason are different.
But I meant a bit different thing, let me clarify.
AFAIU you are trying to unify links in some way. You add operation
as an attribute of the link. My suggestion is that operation
(or action
, kind
, flavor
, etc.) may map to HTTP method
automatically if we give such semantics to it. It is great because it also describes the purpose of the operation:
"@links": {
"foo:a": {
operation: "read", // this is a default operation, corresponds to LO in H-Factors, maps to HTTP GET.
href: "http://example.com/items"
},
"foo:b": {
operation: "append", // corresponds to LN in H-Factors, maps to HTTP POST
type: "json",
href: "http://example.com/items"
},
"foo:c": {
operation: "read",
template: "http://example.com/items/{x}",
parameters:
{
"name": "x",
}
}
...
}
This way linking concept is unified.
Again, this is just the suggestion ;)
Well, I don't really agree with UBER's way of mapping some UBER specific "operation" to a HTTP method in Mason. It makes sense for UBER since it is protocol agnostic - but Mason is not trying to be so.
I can imagine scenarios where "read" can be done with GET as well as POST - like for instance POSTing a big query in order to perform some advanced search..
But continuing on the unification in Mason. It could perhaps make sense to map "type" to "link/template/action" and then use "format" for "any/json/json+files/void". Have to think more about this :-)
The version 2 specification will combine all links, link templates and actions into a single object. Right now the name is "@navigation" but I am looking for something better.
Consider the following scenario:
Now we can take two different approaches: either the client must be prepared to also look into the @actions collection - or we can move all links, link templates and actions into one single @operations collection - with a required "operation" property specifying whether its a link, link template or an action.
In the scenario above it would first be:
and then
In this case the client always looks for "foo:a" in the @operations collection and then switch "operation" to figure out how to handle the operation.
(Would be nice with a better name than "operation" though)