Mais conteúdo relacionado Semelhante a The hypermedia api (20) The hypermedia api2. WHO ARE YOU?
SOFTWARE ENGINEER & MANAGER
Inviqa, Session Digital, Sensio Labs UK
6. RPC
http://.../create_account.php?
email_addr=user@example.com&
passwd_hash=2ab548fae3162ccfa1a2d41a55557a92&
user_name=CrunchAll
9. <user>
<emailaddr>user@example.com</emailaddr>
<username>CrunchAll</username>
</user>
15. CRAFT URLS FOR YOUR
RESOURCES
http://.../users/{name}
http://.../messages/{id}
20. RICHARDSON MATURITY
LEVEL 2
USE THE VERBS THAT HTTP PROVIDES
GET POST PUT DELETE
OPTIONS TRACE HEAD CONNECT PATCH
23. IDENTIFY STATES
LIST USERS, LIST A SINGLE USER
LIST MESSAGES, LIST A SINGLE MESSAGE
CREATE/UPDATE/DELETE A USER
FOLLOW/UNFOLLOW A USER
29. HYPERMEDIA
Hypermedia is used as a logical extension of the term
hypertext in which graphics, audio, video, plain text and
hyperlinks intertwine to create a generally non-linear
medium of information.
38. "_links": {
"next": { "href": "/orders?page=2" },
"self": { "href": "/orders" }
},
"_embedded": { "order": [
"_links": {
"customer": {
"href": "/customer/bob",
"title": "Bob Jones <bob@jones.com>"
},
"self": { "href": "/orders/123" }
},
"currency": "USD", "total": 30
]}
39. <?xml version="1.0"?>
<resource href="/orders">
<link rel="next" href="/orders?page=2"/>
<link rel="search" href="/orders?id={order_id}"/>
<resource rel="order" href="/orders/123">
<link rel="customer" href="/customer/bob" title="Bob Jones <bob@j
ones.com>"/>
<total>30</total>
<currency>USD</currency>
</resource>
</resource>
40. <?php
$hal = new NocarrierHal('/orders');
$hal->addLink('next', '/orders?page=2');
$hal->addLink('search', '/orders?id={order_id}');
$resource = new NocarrierHal(
'/orders/123',
array(
'total' => 30.00,
'currency' => 'GBP',
)
);
$resource->addLink('customer', '/customer/bob', 'Bob Jones <bob@jones
.com>');
$hal->addResource('order', $resource);
echo $hal->asXml();
echo $hal->asJson();
50. {
"name": "Ben",
"phone": "07777000000"
}
51. {
"name": "Ben",
"phone": [ "07777000000", "07777000001" ]
}