Hands-On RESTful Web Services with TypeScript 3
上QQ阅读APP看书,第一时间看更新

Resource-based

One of the key things when a resource is being modeled is the URI definition. The URI is what defines a resource as unique. This representation is what will be returned for clients. If you decided to perform GET to the offer URI, the resource that returns should be a resource representing an order containing the ID order, creation date, and so on. The representation should be in JSON or XML.

Here is a JSON example:

{
id : 1234,
creation-date : "1937-01-01T12:00:27.87+00:20",
any-other-json-fields...
}

Here is an XML example:

<order>
<id>1234</id>
<creation-date>1937-01-01T12:00:27.87+00:20</creation-date>
any-other-xml-fields
</order>