roa - resource oriented architecture

Download ROA - Resource Oriented Architecture

If you can't read please download the document

Upload: javier-lafora-rey

Post on 08-Jun-2015

714 views

Category:

Technology


3 download

DESCRIPTION

Introducción a REST y ROA. Presentación en español para la charla de http://usemyapi.com/ el 12 de mayo de 2012.

TRANSCRIPT

  • 1. INTRODUCCIN A REST Y ROA(Resource Oriented Architecture)

2. Quin es este friki?Twitter: @elafoGithub: eLafo 3. HTTP Protocolo de envo de mensajes en la web El cliente enva una peticin (request) El servidor devuelve una respuesta(response) 4. Request Mtodos Path Cabeceras Cuerpo 5. Ejemplos de requestPOST /Earth/USA/Mount%20Rushmore HTTP/1.1Host: maps.example.comAuthorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=type=national-park&description=We%20visited%20on%203/5/2005GET /index.html HTTP/1.1Host: www.oreilly.comUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12)...Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,...Accept-Language: us,en;q=0.5Accept-Encoding: gzip,deflateAccept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7Keep-Alive: 300Connection: keep-alive 6. Clasificacin de mtodos Mtodos seguros Mtodos idempotentes 7. Listado de mtodos GET PUT DELETE POST HEAD OPTIONS TRACE CONNECT UPDATE 8. Response Cdigo de respuesta Cabeceras Cuerpo 9. Ejemplo de responseHTTP/1.1 200 OKDate: Fri, 17 Nov 2006 15:36:32 GMTServer: ApacheLast-Modified: Fri, 17 Nov 2006 09:05:32 GMTEtag: "7359b7-a7fa-455d8264Accept-Ranges: bytesContent-Length: 43302Content-Type: text/htmlX-Cache: MISS from www.oreilly.comKeep-Alive: timeout=15, max=1000Connection: Keep-Alive... 10. Cmo se define un API? Qu hacer Mtodo HTTP Path Cuerpo Sobre qu Path Cuerpo 11. Tipos de APIs RPC-Style REST REST-RPC HybridRestful web services Leonard Richardson &Sam Ruby (Oreilly) 12. APIs RPC-STYLE Todo en el cuerpoPOST /rpc HTTP/1.1Host: www.upcdatabase.comUser-Agent: XMLRPC::Client (Ruby 1.8.4)Content-Type: text/xml; charset=utf-8Content-Length: 158Connection: keep-alivelookupUPC... 13. APIs REST Accin Mtodo HTTP Scope PathGET /hello.txt HTTP/1.1Host: www.example.com 14. APIs REST-RPC Hybrid (aka RESTmis cojones 33) Todo en el pathGET services/rest?api_key=xxx&method=flickr.photos.search&tags=penguinHTTP/1.1Host: www.flickr.com 15. ROA (Resource OrientedArchitecture)Orientado a recursos(Nosotros decidimos qu es un recurso) 16. ROA (Resource OrientedArchitecture)Cada recurso ha de tener al menos una URI(addressability)/release/20120511/users/elafoTruconsejo: mola que las URIs sean descriptivas /metal/iron_maiden vs /23slhdb/0238ghs 17. ROA (Resource OrientedArchitecture)Un recurso puede tener varias URIsUna URI slo para un recurso/release/20120511/release/lastAunque apunten a la misma informacin, elconcepto puede ser diferente 18. ROA (Resource OrientedArchitecture) Stateleness Cada peticin debe resolverse de forma aisladasin que afecten las anteriores 19. ROA (Resource OrientedArchitecture) Representaciones Idea vs bytes Deberan todas las representaciones devolver lamisma informacin? 20. ROA (Resource OrientedArchitecture) Hypermedia Un recurso debera mostrar los recursosrelacionados por medio de URIs a dichos recursos 21. ROA(Resource OrientedArchitecture)c0363f7260f2f5fcf38d48039f4fb5cab21b060577817310be5170e7774aad70leonardr28crummy.comhttps://s3.amazonaws.com/crummy.com2006-10-26T18:46:45.000Z 22. Preguntas? 23. GRACIAS!!!