Key goal: Separation of concerns
Key goal: Visibility/Scalability/Reliability.
Hint: There is a tradeoff
TRAFFIC
Key goal: Perfomance
CACHEEEE!
Key goal: Simplicity.
CACHEEEE!
Tradeoff ?
Latency on small systems
Key goal: Manteinability.
CACHEEEE!
Optional
Key goal: Simplicity/Consistency.
CACHEEEE!
Resource Structure Description:
Resource: Main building block. Name it and its a resource.
A way to communicate.
{
"date": "2014-10-25",
"max_temp": 25.5,
"min_temp": 10.0,
"temp_unit": "C",
"humidity_percentage": 75.0,
"cloud_coverage": "low"
} <?xml version='1.0' encoding='UTF-8' ?>
<root>
<temp_unit value="C" />
<humidity_percentage value="75.0" />
<cloud_coverage value="low" />
<date value="2014-10-25" />
<min_temp value="10.0" />
<max_temp value="25.5" />
</root> 2014-10-25|25.5|10.0|C|75.0|low Representation could be requested: Content Negotiation/ extension
Also known as: URI
full URI
GET /api/v1/books /j-k-rowling/harry-potter-and-the-deathly-hollowsURI should always return the same resource.
GET /api/v1/books/last Not very "restful":
Manipulation through Representation:
GET
POST
PUT
DELETE
OPTIONS
Respect Status Code!!
Hypermedia as the Engine of Application State
Every Resources have METADATA
Metadata are just LINKS!
Basic Root endpoint: GET /api/v1
{
"metadata": {
"links": [
"books": {
"uri": "/books",
"content-type": "application/json"
},
"authors": {
"uri": "/authors",
"content-type": "application/json"
}
]
}
} Powered Root endpoint: GET /api/v1
{
"resources": [
{
"title": "Harry Potter and the Half Blood prince",
"description": "......",
"author": {
"name": "J.K.Rowling",
"metadata": {
"links": {
"data": {
"uri": "/authors/j-k-rowling",
"content-type": "application/json"
},
"books": {
"uri": "/authors/j-k-rowling/books",
"content-type": "application/json"
}
}
}
}
}
... metadata structure is an Architecture decition
Define a Representation with Resources links and state.
{
"_embedded": [
{
"title": "Harry Potter and the Half Blood prince",
"description": "......",
"copies": 10,
"_embedded": {
"author": {
"name": "J.K.Rowling",
"_links": {
"self": {
"href": "/authors/j-k-rowling",
"type": "application/json+hal"
},
"books": {
"href": "/authors/j-k-rowling/books",
"type": "application/json+hal"
}
}
}
}
}
]
}