SlideShare une entreprise Scribd logo
1  sur  30
 
 
Cos’è  REST ?
REST  non è un  Protocollo un’ Architettura un  Software uno  Standard un nome carino per  Web Services una  Buzzword
Re presentational S tate T ransfer Roy T. Fielding “ Architectural Styles and Design of Network-based Software Architectures” Ph.D dissertation, 2000
REST  è uno  stile architetturale  per applicazioni di rete , un insieme di  vincoli  e  principi  che, se seguiti, portano come risultato un’ architettura  semplice e scalabile
REST : principi ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
REST : le risorse Le risorse sono  fonti di informazioni  accessibili attraverso un  URI . Il  client  può attraverso un  protocollo  di comunicazione standard (ad es. http) ottenere una risorsa dal  server. Le risorse sono disponibili in diverse  rappresentazioni  (ad es. XML, JSON, PNG)
HTTP  è  REST ful ma  REST  non è  HTTP
HTTP GET  /reviews/?filter=letter&letter=a  HTTP/1.1 Host: www.goblins.net Connection: Close HTTP/1.1 200 OK Content-Type: application/xml; charset=UTF-8 <?xml version= &quot;1.0&quot; encoding=&quot;UTF-8&quot; ?> <root> <reviews> <review id= “1&quot; title=“Agricola&quot; > <descrizione>Agricola è un gioco…</descrizione> … </review> <review id= “2&quot; title=“Risiko&quot; > <descrizione>…</descrizione> … </review> </reviews> </root>
HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/php Connection: Close HTTP/1.1 200 OK Content-Type: application/php; charset=UTF-8 Connection: Close a:296:{i:0;a:33:{s:2:&quot;id&quot;;s:4:&quot;3791&quot;;s:4:&quot;date&quot;;s:10:&quot;2008-01-28&quot;;s:5:&quot;title&quot;;s:18:&quot;A Caccia con Papà&quot;;s:8:&quot;reviewer&quot;;s…
HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/json Connection: Close HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Connection: Close [{&quot;id&quot;:&quot;3791&quot;,&quot;date&quot;:&quot;2008-01-28&quot;,&quot;title&quot;:&quot;A Caccia con Pap00e0&quot;,&quot;reviewer&quot;: &quot;Lobo&quot;,&quot;email&quot;:&quot;sdp@sdp.net&quot;,&quot;s …
HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: text/yml Connection: Close HTTP/1.1 200 OK Content-Type: text/yml; charset=UTF-8 Connection: Close -  id: '3791‘ date: '2008-01-28‘ title: 'A Caccia con Papà‘ reviewer: Lobo email: sdp@sdhjp.net score: '0‘ cover: '‘ url: '‘ url_title: '‘ hits: '500‘ …
HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/php Accept-Language: it Connection: Close HTTP/1.1 200 OK Content-Type: application/php; charset=UTF-8 Connection: Close a:296:{i:0;a:33:{s:2:&quot;id&quot;;s:4:&quot;3791&quot;;s:4:&quot;date&quot;;s:10:&quot;2008-01-28&quot;;s:5:&quot;title&quot;;s:18:&quot;A Caccia con Papà&quot;;s:8:&quot;reviewer&quot;;s…
HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/php Accept-Encoding: compress Connection: Close HTTP/1.1 200 OK Content-Type: application/php; charset=UTF-8 Content-Encoding: compress Vary: Accept-Encoding Connection: Close #@°&%&%%$&%@°...
HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/php; q=0.8, application/json, text/yml; q=0.5 Connection: Close HTTP/1.1 200 OK Content-Type: application/php; charset=UTF-8 Connection: Close a:296:{i:0;a:33:{s:2:&quot;id&quot;;s:4:&quot;3791&quot;;s:4:&quot;date&quot;;s:10:&quot;2008-01-28&quot;;s:5:&quot;title&quot;;s:18:&quot;A Caccia con Papà&quot;;s:8:&quot;reviewer&quot;;s…
 
 
 
MODEL
MODEL VIEW
VIEW
$data = array( 1 => array('ID'=>1, 'title'=>'Agricola', ...), 2 => array('ID'=>2, 'title'=>'Risiko', ...), ... ) //reviews.html <?xml version= &quot;1.0&quot; encoding=&quot;UTF-8&quot; ?> <root> <reviews> {% for i, r in reviews %} <review id= &quot;{{r.id}}&quot; title=&quot;{{r.title}}&quot; > {% for key, value in r %} <{{key}}>{{value}}</{{key}}> {% endfor %}  </review> {% else %} <noresult>No result for this query</noresult> {% endfor %} </reviews> </root> <?xml version= &quot;1.0&quot; encoding=&quot;UTF-8&quot; ?> <root> <reviews> <review id= “1&quot; title=“Agricola&quot; > <descrizione>Agricola è un gioco…</descrizione> … </review> <review id= “2&quot; title=“Risiko&quot; > <descrizione>…</descrizione> … </review> </reviews> </root>
/reviews/?filter=letter&letter=a /reviews/5 /reviews/5/comments … .htaccess dispatch.php CONTROLLER web
/reviews/?filter=letter&letter=a /reviews/5 /reviews/5/comments … .htaccess dispatch.php CONTROLLER web
/reviews/?filter=letter&letter=a /reviews/5 /reviews/5/comments … .htaccess dispatch.php CONTROLLER //dispatch.php … $request = new Request( $config = array() ); $resource = $request->loadResource(); $response = $resource->exec($request); $response->output(); web
//ReviewResource.php <?php /** * The Review Collection *  @uri /reviews(/(.)*)? */ class ReviewsResource extends Resource { /** * Handle a GET request for this resource *  @param Request request *  @return Response */ function get($request) { $response = new Response($request); $etag = md5($request->uri); if ($request->ifNoneMatch($etag)) { $response->code =  Response::NOTMODIFIED ; } else { $response->code = Response::OK ; $response->addHeader('Content-type', 'text/html; charset=&quot;UTF-8&quot;'); $headers = $this-> selectHeaders ($request); foreach($headers as $key => $value) $response->addHeader($key, $value); $response->addEtag($etag); $response->body = $this-> selectBody ($request); } return $response; } … }
On code
/reviews/5
web

Contenu connexe

Similaire à A simple ReSTful webservice for the Goblins (v. 0.5)

An Overview on PROV-AQ: Provenance Access and Query
An Overview on PROV-AQ: Provenance Access and QueryAn Overview on PROV-AQ: Provenance Access and Query
An Overview on PROV-AQ: Provenance Access and QueryOlaf Hartig
 
RESTful Web Services and Drupal
RESTful Web Services and DrupalRESTful Web Services and Drupal
RESTful Web Services and DrupalGreg Hines
 
GTAC: AtomPub, testing your server implementation
GTAC: AtomPub, testing your server implementationGTAC: AtomPub, testing your server implementation
GTAC: AtomPub, testing your server implementationDavid Calavera
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructureguest517f2f
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMWoody Pewitt
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座Li Yi
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructureguest517f2f
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7phuphax
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Michiel Rook
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPStephan Schmidt
 
Agile Descriptions
Agile DescriptionsAgile Descriptions
Agile DescriptionsTony Hammond
 
Migration testing framework
Migration testing frameworkMigration testing framework
Migration testing frameworkIndicThreads
 
Silver Light By Nyros Developer
Silver Light By Nyros DeveloperSilver Light By Nyros Developer
Silver Light By Nyros DeveloperNyros Technologies
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page CreationWildan Maulana
 

Similaire à A simple ReSTful webservice for the Goblins (v. 0.5) (20)

Putting SOAP to REST
Putting SOAP to RESTPutting SOAP to REST
Putting SOAP to REST
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
 
An Overview on PROV-AQ: Provenance Access and Query
An Overview on PROV-AQ: Provenance Access and QueryAn Overview on PROV-AQ: Provenance Access and Query
An Overview on PROV-AQ: Provenance Access and Query
 
RESTful Web Services and Drupal
RESTful Web Services and DrupalRESTful Web Services and Drupal
RESTful Web Services and Drupal
 
GTAC: AtomPub, testing your server implementation
GTAC: AtomPub, testing your server implementationGTAC: AtomPub, testing your server implementation
GTAC: AtomPub, testing your server implementation
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAM
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7
 
Xml
XmlXml
Xml
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHP
 
Agile Descriptions
Agile DescriptionsAgile Descriptions
Agile Descriptions
 
Migration testing framework
Migration testing frameworkMigration testing framework
Migration testing framework
 
REST dojo Comet
REST dojo CometREST dojo Comet
REST dojo Comet
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
Ajax ons2
Ajax ons2Ajax ons2
Ajax ons2
 
Silver Light By Nyros Developer
Silver Light By Nyros DeveloperSilver Light By Nyros Developer
Silver Light By Nyros Developer
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page Creation
 

Dernier

call Now 9811711561 Cash Payment乂 Call Girls in Dwarka
call Now 9811711561 Cash Payment乂 Call Girls in Dwarkacall Now 9811711561 Cash Payment乂 Call Girls in Dwarka
call Now 9811711561 Cash Payment乂 Call Girls in Dwarkavikas rana
 
WOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxWOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxpadhand000
 
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)Delhi Call girls
 
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morcall Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morvikas rana
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfpastor83
 
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)Delhi Call girls
 
the Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationthe Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationbrynpueblos04
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...Cara Menggugurkan Kandungan 087776558899
 
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)Delhi Call girls
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theorydrae5
 
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)Delhi Call girls
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...mitaliverma221
 

Dernier (14)

call Now 9811711561 Cash Payment乂 Call Girls in Dwarka
call Now 9811711561 Cash Payment乂 Call Girls in Dwarkacall Now 9811711561 Cash Payment乂 Call Girls in Dwarka
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka
 
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
 
WOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxWOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptx
 
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
 
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morcall Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdf
 
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
 
the Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationthe Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentation
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
 
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
 
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theory
 
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Jasola (Delhi)
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
 

A simple ReSTful webservice for the Goblins (v. 0.5)

  • 1.  
  • 2.  
  • 4. REST non è un Protocollo un’ Architettura un Software uno Standard un nome carino per Web Services una Buzzword
  • 5. Re presentational S tate T ransfer Roy T. Fielding “ Architectural Styles and Design of Network-based Software Architectures” Ph.D dissertation, 2000
  • 6. REST è uno stile architetturale per applicazioni di rete , un insieme di vincoli e principi che, se seguiti, portano come risultato un’ architettura semplice e scalabile
  • 7.
  • 8. REST : le risorse Le risorse sono fonti di informazioni accessibili attraverso un URI . Il client può attraverso un protocollo di comunicazione standard (ad es. http) ottenere una risorsa dal server. Le risorse sono disponibili in diverse rappresentazioni (ad es. XML, JSON, PNG)
  • 9. HTTP è REST ful ma REST non è HTTP
  • 10. HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Connection: Close HTTP/1.1 200 OK Content-Type: application/xml; charset=UTF-8 <?xml version= &quot;1.0&quot; encoding=&quot;UTF-8&quot; ?> <root> <reviews> <review id= “1&quot; title=“Agricola&quot; > <descrizione>Agricola è un gioco…</descrizione> … </review> <review id= “2&quot; title=“Risiko&quot; > <descrizione>…</descrizione> … </review> </reviews> </root>
  • 11. HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/php Connection: Close HTTP/1.1 200 OK Content-Type: application/php; charset=UTF-8 Connection: Close a:296:{i:0;a:33:{s:2:&quot;id&quot;;s:4:&quot;3791&quot;;s:4:&quot;date&quot;;s:10:&quot;2008-01-28&quot;;s:5:&quot;title&quot;;s:18:&quot;A Caccia con Papà&quot;;s:8:&quot;reviewer&quot;;s…
  • 12. HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/json Connection: Close HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Connection: Close [{&quot;id&quot;:&quot;3791&quot;,&quot;date&quot;:&quot;2008-01-28&quot;,&quot;title&quot;:&quot;A Caccia con Pap00e0&quot;,&quot;reviewer&quot;: &quot;Lobo&quot;,&quot;email&quot;:&quot;sdp@sdp.net&quot;,&quot;s …
  • 13. HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: text/yml Connection: Close HTTP/1.1 200 OK Content-Type: text/yml; charset=UTF-8 Connection: Close - id: '3791‘ date: '2008-01-28‘ title: 'A Caccia con Papà‘ reviewer: Lobo email: sdp@sdhjp.net score: '0‘ cover: '‘ url: '‘ url_title: '‘ hits: '500‘ …
  • 14. HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/php Accept-Language: it Connection: Close HTTP/1.1 200 OK Content-Type: application/php; charset=UTF-8 Connection: Close a:296:{i:0;a:33:{s:2:&quot;id&quot;;s:4:&quot;3791&quot;;s:4:&quot;date&quot;;s:10:&quot;2008-01-28&quot;;s:5:&quot;title&quot;;s:18:&quot;A Caccia con Papà&quot;;s:8:&quot;reviewer&quot;;s…
  • 15. HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/php Accept-Encoding: compress Connection: Close HTTP/1.1 200 OK Content-Type: application/php; charset=UTF-8 Content-Encoding: compress Vary: Accept-Encoding Connection: Close #@°&%&%%$&%@°...
  • 16. HTTP GET /reviews/?filter=letter&letter=a HTTP/1.1 Host: www.goblins.net Accept: application/php; q=0.8, application/json, text/yml; q=0.5 Connection: Close HTTP/1.1 200 OK Content-Type: application/php; charset=UTF-8 Connection: Close a:296:{i:0;a:33:{s:2:&quot;id&quot;;s:4:&quot;3791&quot;;s:4:&quot;date&quot;;s:10:&quot;2008-01-28&quot;;s:5:&quot;title&quot;;s:18:&quot;A Caccia con Papà&quot;;s:8:&quot;reviewer&quot;;s…
  • 17.  
  • 18.  
  • 19.  
  • 20. MODEL
  • 22. VIEW
  • 23. $data = array( 1 => array('ID'=>1, 'title'=>'Agricola', ...), 2 => array('ID'=>2, 'title'=>'Risiko', ...), ... ) //reviews.html <?xml version= &quot;1.0&quot; encoding=&quot;UTF-8&quot; ?> <root> <reviews> {% for i, r in reviews %} <review id= &quot;{{r.id}}&quot; title=&quot;{{r.title}}&quot; > {% for key, value in r %} <{{key}}>{{value}}</{{key}}> {% endfor %} </review> {% else %} <noresult>No result for this query</noresult> {% endfor %} </reviews> </root> <?xml version= &quot;1.0&quot; encoding=&quot;UTF-8&quot; ?> <root> <reviews> <review id= “1&quot; title=“Agricola&quot; > <descrizione>Agricola è un gioco…</descrizione> … </review> <review id= “2&quot; title=“Risiko&quot; > <descrizione>…</descrizione> … </review> </reviews> </root>
  • 24. /reviews/?filter=letter&letter=a /reviews/5 /reviews/5/comments … .htaccess dispatch.php CONTROLLER web
  • 25. /reviews/?filter=letter&letter=a /reviews/5 /reviews/5/comments … .htaccess dispatch.php CONTROLLER web
  • 26. /reviews/?filter=letter&letter=a /reviews/5 /reviews/5/comments … .htaccess dispatch.php CONTROLLER //dispatch.php … $request = new Request( $config = array() ); $resource = $request->loadResource(); $response = $resource->exec($request); $response->output(); web
  • 27. //ReviewResource.php <?php /** * The Review Collection * @uri /reviews(/(.)*)? */ class ReviewsResource extends Resource { /** * Handle a GET request for this resource * @param Request request * @return Response */ function get($request) { $response = new Response($request); $etag = md5($request->uri); if ($request->ifNoneMatch($etag)) { $response->code = Response::NOTMODIFIED ; } else { $response->code = Response::OK ; $response->addHeader('Content-type', 'text/html; charset=&quot;UTF-8&quot;'); $headers = $this-> selectHeaders ($request); foreach($headers as $key => $value) $response->addHeader($key, $value); $response->addEtag($etag); $response->body = $this-> selectBody ($request); } return $response; } … }
  • 30. web