RESTful Web Service usage of custom link relations

2019-04-06 22:47发布

问题:

I'm working on a RESTful service and have been focusing on Discoverability, Link relations - 'rel' and microformats. I'm not clear about the values of 'rel' in the context of REST - am I allowed to make use of any custom value, to provide richer semantics or should I only use the default values (which are very constraining)?

I am aware that microformats have indeed extended the values of 'rel', but I am not using any kind of microformat yet.

Any help is appreciated. Thanks.

回答1:

Link Relations (rel) are one of the two ways that you can convey semantics to a client. The other way is media types.

The best spec to read on Web linking is here http://tools.ietf.org/html/rfc5988.

The link relation registry is here http://www.iana.org/assignments/link-relations/link-relations.xml.

And for an example of how to use link relations to convey semantics you can look a the Hal media type. It is a generic media type that uses link relations to convey all of its semantic meaning. http://stateless.co/hal_specification.html