HATEOAS links with PUT/POST

后端 未结 2 1269
别那么骄傲
别那么骄傲 2021-01-11 09:36

What would be the best way to represent a HATEOAS link for a POST/PUT/PATCH on a resource? These operations have payload but we won\'t

2条回答
  •  孤城傲影
    2021-01-11 10:11

    Links are comprised of two elements: href and rel. The href contains the explicit URL to locate a resource. The rel identifies the relationship between the current resource and the link's resource. The rel should be used to determine what HTTP method is acceptable and how the link should be used.

    The following is a quote from RESTful Web Services Cookbook section 5.4:

    A link relation type conveys the role or purpose of a link. Once clients and servers agree on the meaning of these types, clients can find and use URIs from links.

    For example, edit is a standard link relation that has explicit details including details around using GET, PUT, POST, DELETE.

    Link relations can be extended and you can add your own.

提交回复
热议问题