-
In REST, do we always use link relation values to convey semantics/role of a linked resource?
-
I assume link relation value is always specified using
rel
attribute? -
Should
rel
attribute only be specified within a hypermedia control? -
I assume for an element to be considered a hypermedia control it must provide a linking functionality and must also contain a
rel
attribute?
In REST, do we always use link relation values to convey
semantics/role of a linked resource?
Using link relations is just one way to add semantics to links. The other standard solution to use RDF vocabs, for example hydra or schema.org.
I assume link relation value is always specified using rel attribute?
This depends on the media type, for example by HAL+JSON you do something like this:
{
"nick": "John",
"_links": {
"self": {
"href": "http://example.com/users/john"
}
}
}
Should rel attribute only be specified within a hypermedia control?
I assume for an element to be considered a hypermedia control it must
provide a linking functionality and must also contain a rel attribute?
That again depends on the media type. For example by HTML only LINK elements can have relations, so you can add semantics only to GET requests. Other elements which use hyperlinks as well – for example FORM, IMG, etc. – cannot have relations as far as I know. By them you can use RDFa to add link relation. Btw. HTML is not the best hypermedia type for REST, since it is about machine to machine communication and HTML is for building GUIs for humans…