Prof. Cesare Pautasso
http://www.pautasso.info
[email protected]
@pautasso
REST defines the architectural style of the Web
GET
(query the state, read-only) PUT
(Create/Update a resource, idempotent)DELETE
(Delete a resource, idempotent)POST
(Create/Access a resource)REST middleware is primarily designed to scale a single server, which may need to service a large number of clients
A Composite REST service provides an aggregated view over the state of multiple REST services
The behavior of /C is defined by
composing /R and /S
The composite resource /C only aggregates
the state of its components /R and /S
The composite resource /C augments or
caches the state of its components
The composite representation C refers to its component resources /R and /S via hyperlinks
A composite representation is interpreted by the client that follows its hyperlinks and aggregates the state of the referenced component resources
A composite representation may be retrieved from a composite service
Vote to choose a meeting place based on its geographic location
Compose Yahoo! Local Search with Doodle
Create a new poll using the locations
How to program a composite resource?
Business Process Modeling
Scripting Languages
PPOPP 2012
service S {
res '/hello' on GET {
//handle GET request
respond 'World!';
}
}
Request handlers contain any JavaScript code (with some S extensions)
service Proxy {
res '/hello1' on GET {
respond get '/hello2';
}
res '/hello2' on GET {
respond get 'http://api.inf.usi.ch/';
}
}
service Composition {
res '/search' on GET {
res a = 'http://www.bing.com/?q=$query';
res b = 'http://www.google.com/?q=$query';
respond a.get + b.get;
}
}
service Stateful {
res '/hello' {
state s = 'World'
on GET {
respond 'Hello ' + s
}
on PUT {
s = $name
}
}
}
service DoodleMap {
res '/doodlemap' {
state id = 0;
on POST {
res yls = 'http://local.yahooapis.com/search' +
'?query=$query&zip=$zip';
res doodle = 'http://doodle-test.com/.../polls'
var local = yls.get;
var pollurl = doodle.post(xml_format(local,$title));
state ui_html[id++] = render('GoogleMap', local, pollurl);
res id {
on GET {
respond ui_html[$id];
}
}
respond { 302: {"Location": "/doodlemap/"+id}}
var timer = setInterval(function() {
var pollState = res(pollurl).get;
var participants = countParticipants(pollState);
if (participants == $maxParticipants) {
res(pollurl).put("closed");
clearInterval(timer);
}
},1000);
}
}
}
Use a spacebar or arrow keys to navigate