HATEOAS, an abbreviation for Hypermedia As The Engine Of Application State, is a constraint of the REST application architecture that distinguishes it from most other network application architectures. The principle is that a client interacts with a network application entirely through hypermedia provided dynamically by application servers. A REST client needs no prior knowledge about how to interact with any particular application or server beyond a generic understanding of hypermedia. By contrast, in some service-oriented architectures (SOA), clients and servers interact through a fixed interface shared through documentation or an interface description language (IDL).
The HATEOAS constraint decouples client and server in a way that allows the server functionality to evolve independently.
For example, [2] here is a GET request to fetch an Account resource, requesting details in an XML representation:
GET /account/12345 HTTP/1.1
Host: bank.example.com
Accept: application/xml
...
Here is the response:
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: ...
<?xml version="1.0"?>
<account>
<account_number>12345</account_number>
<balance currency="usd">100.00</balance>
<link rel="deposit" href="https://bank.example.com/account/12345/deposit" />
<link rel="withdraw" href="https://bank.example.com/account/12345/withdraw" />
<link rel="transfer" href="https://bank.example.com/account/12345/transfer" />
<link rel="close" href="https://bank.example.com/account/12345/close" />
</account>
No comments:
Post a Comment