SlideShare una empresa de Scribd logo
INTRODUCCIÓN A REST Y ROA
(Resource Oriented Architecture)
¿Quién es este friki?
Twitter: @elafo
Github: eLafo
HTTP
●   Protocolo de envío de mensajes en la web
●   El cliente envía una petición (request)
●   El servidor devuelve una respuesta(response)
Request
●   Métodos
●   Path
●   Cabeceras
●   Cuerpo
Ejemplos de request
POST /Earth/USA/Mount%20Rushmore HTTP/1.1
Host: maps.example.com
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
type=national-park&description=We%20visited%20on%203/5/2005


GET /index.html HTTP/1.1
Host: www.oreilly.com
User-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.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Clasificación de métodos
●   Métodos seguros
●   Métodos idempotentes
Listado de métodos
●   GET
●   PUT
●   DELETE
●   POST
●   HEAD
●   OPTIONS
●   TRACE
●   CONNECT
●   UPDATE
Response
●   Código de respuesta
●   Cabeceras
●   Cuerpo
Ejemplo de response
HTTP/1.1 200 OK
Date: Fri, 17 Nov 2006 15:36:32 GMT
Server: Apache
Last-Modified: Fri, 17 Nov 2006 09:05:32 GMT
Etag: "7359b7-a7fa-455d8264
Accept-Ranges: bytes
Content-Length: 43302
Content-Type: text/html
X-Cache: MISS from www.oreilly.com
Keep-Alive: timeout=15, max=1000
Connection: Keep-Alive


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
...


●
¿Cómo se define un API?
●   Qué hacer
    –   Método HTTP
    –   Path
    –   Cuerpo
●   Sobre qué
    –   Path
    –   Cuerpo
Tipos de APIs
●   RPC-Style
●   REST
●   REST-RPC Hybrid



    Restful web services – Leonard Richardson &
    Sam Ruby (O'reilly)
APIs RPC-STYLE
●     Todo en el cuerpo
POST /rpc HTTP/1.1
Host: www.upcdatabase.com
User-Agent: XMLRPC::Client (Ruby 1.8.4)
Content-Type: text/xml; charset=utf-8
Content-Length: 158
Connection: keep-alive
<?xml version="1.0" ?>
<methodCall>
<methodName>lookupUPC</methodName>
...
</methodCall>
APIs REST
●   Acción → Método HTTP
●   Scope → Path



    GET /hello.txt HTTP/1.1
    Host: www.example.com
APIs REST-RPC Hybrid (aka REST
        mis cojones 33)
●   Todo en el path




    GET services/rest?api_key=xxx&method=flickr.photos.search&tags=penguin
    HTTP/1.1
    Host: www.flickr.com
ROA (Resource Oriented
          Architecture)
Orientado a recursos
(Nosotros decidimos qué es un recurso)
ROA (Resource Oriented
            Architecture)
Cada recurso ha de tener al menos una URI
(addressability)
/release/20120511
/users/elafo


Truconsejo: mola que las URIs sean descriptivas
–   /metal/iron_maiden vs /23slhdb/0238ghs
ROA (Resource Oriented
          Architecture)
Un recurso puede tener varias URIs
Una URI sólo para un recurso
/release/20120511
/release/last


Aunque apunten a la misma información, el
concepto puede ser diferente
ROA (Resource Oriented
                Architecture)
●   Stateleness
    –   Cada petición debe resolverse de forma aislada
        sin que afecten las anteriores
ROA (Resource Oriented
                Architecture)
●   Representaciones
    –   Idea vs bytes
    –   ¿Deberían todas las representaciones devolver la
        misma información?
ROA (Resource Oriented
                Architecture)
●   Hypermedia
    –   Un recurso debería mostrar los recursos
        relacionados por medio de URIs a dichos recursos
ROA(Resource Oriented
                Architecture)
<?xml version='1.0' encoding='UTF-8'?>
<ListAllMyBucketsResult xmlns='http://s3.amazonaws.com/doc/2006-03-01/'>
  <Owner>
     <ID>c0363f7260f2f5fcf38d48039f4fb5cab21b060577817310be5170e7774aad70</ID>
     <DisplayName>leonardr28</DisplayName>
  </Owner>
  <Buckets>
     <Bucket>
       <Name>crummy.com</Name>
       <URI>https://s3.amazonaws.com/crummy.com</URI>
       <CreationDate>2006-10-26T18:46:45.000Z</CreationDate>
     </Bucket>
  </Buckets>
</ListAllMyBucketsResult>
¿Preguntas?
¡¡¡GRACIAS!!!

Más contenido relacionado

PDF
Jvmmx jigsaw
PDF
Jvmmx docker jvm
PDF
Redis no es solo una caché
PDF
Aprendiendo REDIS en 20 minutos
PDF
Taller Redis
PPSX
ODP
Node.js - Eventos para Todos
PDF
Construyendo Aplicaciones Web con PHP + LUA + REDIS
Jvmmx jigsaw
Jvmmx docker jvm
Redis no es solo una caché
Aprendiendo REDIS en 20 minutos
Taller Redis
Node.js - Eventos para Todos
Construyendo Aplicaciones Web con PHP + LUA + REDIS

Similar a ROA - Resource Oriented Architecture (20)

PDF
Open Source Modern Web Development
PDF
Introducció a les Aplicació Web
PPTX
Tecnologias Web Semantica
PDF
Apache
ODP
Protocolo http
ODP
Apache ha muerto, Viva Lighttpd
PDF
Http 1.1 clase 4 - curso front-end 2014 - open webinars
PPTX
Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011
ODP
RESTful APIs con Tastypie
PDF
PPTX
Fundamentos de la web
PDF
Apache avanzado
PDF
Screen scraping
PPTX
Arquitectura de la Web y Computación en el Servidor
PPTX
Tecnologias Web Semantica
PDF
Generación de web sites dinámicos usando php
PDF
Generación de web sites dinámicos usando php
PDF
(20.05.2009) Cumuy Presenta - Más tecnologías interesantes para conocer - PPT 1
ODP
Desarrollando un API con REST
Open Source Modern Web Development
Introducció a les Aplicació Web
Tecnologias Web Semantica
Apache
Protocolo http
Apache ha muerto, Viva Lighttpd
Http 1.1 clase 4 - curso front-end 2014 - open webinars
Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011
RESTful APIs con Tastypie
Fundamentos de la web
Apache avanzado
Screen scraping
Arquitectura de la Web y Computación en el Servidor
Tecnologias Web Semantica
Generación de web sites dinámicos usando php
Generación de web sites dinámicos usando php
(20.05.2009) Cumuy Presenta - Más tecnologías interesantes para conocer - PPT 1
Desarrollando un API con REST
Publicidad

Más de Javier Lafora Rey (8)

PDF
An introduction to Vue.js
PPTX
Modular development with redux
ODP
Understanding big data-drupalcamp
ODP
API REST for beginners or why you should make your API understandable
PDF
APIs para gente normal
ODP
¿Por qué ruby on rails?
ODP
Ruby object model: A matter of life and death
ODP
How to use git without rage
An introduction to Vue.js
Modular development with redux
Understanding big data-drupalcamp
API REST for beginners or why you should make your API understandable
APIs para gente normal
¿Por qué ruby on rails?
Ruby object model: A matter of life and death
How to use git without rage
Publicidad

Último (20)

PPTX
ANCASH-CRITERIOS DE EVALUACIÓN-FORMA-10-10 (2).pptx
PPTX
Sesion 1 de microsoft power point - Clase 1
PPTX
Presentación PASANTIAS AuditorioOO..pptx
PDF
clase auditoria informatica 2025.........
PPTX
REDES INFORMATICAS REDES INFORMATICAS.pptx
PPTX
RAP02 - TECNICO SISTEMAS TELEINFORMATICOS.pptx
PDF
5.1 Pinch y Bijker en libro Actos, actores y artefactos de Bunch Thomas (coor...
PDF
Diapositiva proyecto de vida, materia catedra
PDF
CyberOps Associate - Cisco Networking Academy
PDF
programa-de-estudios-2011-guc3ada-para-el-maestro-secundarias-tecnicas-tecnol...
PDF
taller de informática - LEY DE OHM
PPTX
RAP01 - TECNICO SISTEMAS TELEINFORMATICOS.pptx
PPTX
COMO AYUDAN LAS TIC EN LA EDUCACION SUPERIOR.pptx
PPTX
sa-cs-82-powerpoint-hardware-y-software_ver_4.pptx
PPTX
historia_web de la creacion de un navegador_presentacion.pptx
PDF
Estrategia de apoyo tecnología miguel angel solis
PDF
Instrucciones simples, respuestas poderosas. La fórmula del prompt perfecto.
PPTX
IA de Cine - Como MuleSoft y los Agentes estan redefiniendo la realidad
PPTX
Power Point Nicolás Carrasco (disertación Roblox).pptx
PDF
SAP Transportation Management para LSP, TM140 Col18
ANCASH-CRITERIOS DE EVALUACIÓN-FORMA-10-10 (2).pptx
Sesion 1 de microsoft power point - Clase 1
Presentación PASANTIAS AuditorioOO..pptx
clase auditoria informatica 2025.........
REDES INFORMATICAS REDES INFORMATICAS.pptx
RAP02 - TECNICO SISTEMAS TELEINFORMATICOS.pptx
5.1 Pinch y Bijker en libro Actos, actores y artefactos de Bunch Thomas (coor...
Diapositiva proyecto de vida, materia catedra
CyberOps Associate - Cisco Networking Academy
programa-de-estudios-2011-guc3ada-para-el-maestro-secundarias-tecnicas-tecnol...
taller de informática - LEY DE OHM
RAP01 - TECNICO SISTEMAS TELEINFORMATICOS.pptx
COMO AYUDAN LAS TIC EN LA EDUCACION SUPERIOR.pptx
sa-cs-82-powerpoint-hardware-y-software_ver_4.pptx
historia_web de la creacion de un navegador_presentacion.pptx
Estrategia de apoyo tecnología miguel angel solis
Instrucciones simples, respuestas poderosas. La fórmula del prompt perfecto.
IA de Cine - Como MuleSoft y los Agentes estan redefiniendo la realidad
Power Point Nicolás Carrasco (disertación Roblox).pptx
SAP Transportation Management para LSP, TM140 Col18

ROA - Resource Oriented Architecture

  • 1. INTRODUCCIÓN A REST Y ROA (Resource Oriented Architecture)
  • 2. ¿Quién es este friki? Twitter: @elafo Github: eLafo
  • 3. HTTP ● Protocolo de envío de mensajes en la web ● El cliente envía una petición (request) ● El servidor devuelve una respuesta(response)
  • 4. Request ● Métodos ● Path ● Cabeceras ● Cuerpo
  • 5. Ejemplos de request POST /Earth/USA/Mount%20Rushmore HTTP/1.1 Host: maps.example.com Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= type=national-park&description=We%20visited%20on%203/5/2005 GET /index.html HTTP/1.1 Host: www.oreilly.com User-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.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive
  • 6. Clasificación de métodos ● Métodos seguros ● Métodos idempotentes
  • 7. Listado de métodos ● GET ● PUT ● DELETE ● POST ● HEAD ● OPTIONS ● TRACE ● CONNECT ● UPDATE
  • 8. Response ● Código de respuesta ● Cabeceras ● Cuerpo
  • 9. Ejemplo de response HTTP/1.1 200 OK Date: Fri, 17 Nov 2006 15:36:32 GMT Server: Apache Last-Modified: Fri, 17 Nov 2006 09:05:32 GMT Etag: "7359b7-a7fa-455d8264 Accept-Ranges: bytes Content-Length: 43302 Content-Type: text/html X-Cache: MISS from www.oreilly.com Keep-Alive: timeout=15, max=1000 Connection: Keep-Alive <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> ... ●
  • 10. ¿Cómo se define un API? ● Qué hacer – Método HTTP – Path – Cuerpo ● Sobre qué – Path – Cuerpo
  • 11. Tipos de APIs ● RPC-Style ● REST ● REST-RPC Hybrid Restful web services – Leonard Richardson & Sam Ruby (O'reilly)
  • 12. APIs RPC-STYLE ● Todo en el cuerpo POST /rpc HTTP/1.1 Host: www.upcdatabase.com User-Agent: XMLRPC::Client (Ruby 1.8.4) Content-Type: text/xml; charset=utf-8 Content-Length: 158 Connection: keep-alive <?xml version="1.0" ?> <methodCall> <methodName>lookupUPC</methodName> ... </methodCall>
  • 13. APIs REST ● Acción → Método HTTP ● Scope → Path GET /hello.txt HTTP/1.1 Host: www.example.com
  • 14. APIs REST-RPC Hybrid (aka REST mis cojones 33) ● Todo en el path GET services/rest?api_key=xxx&method=flickr.photos.search&tags=penguin HTTP/1.1 Host: www.flickr.com
  • 15. ROA (Resource Oriented Architecture) Orientado a recursos (Nosotros decidimos qué es un recurso)
  • 16. ROA (Resource Oriented Architecture) Cada recurso ha de tener al menos una URI (addressability) /release/20120511 /users/elafo Truconsejo: mola que las URIs sean descriptivas – /metal/iron_maiden vs /23slhdb/0238ghs
  • 17. ROA (Resource Oriented Architecture) Un recurso puede tener varias URIs Una URI sólo para un recurso /release/20120511 /release/last Aunque apunten a la misma información, el concepto puede ser diferente
  • 18. ROA (Resource Oriented Architecture) ● Stateleness – Cada petición debe resolverse de forma aislada sin que afecten las anteriores
  • 19. ROA (Resource Oriented Architecture) ● Representaciones – Idea vs bytes – ¿Deberían todas las representaciones devolver la misma información?
  • 20. ROA (Resource Oriented Architecture) ● Hypermedia – Un recurso debería mostrar los recursos relacionados por medio de URIs a dichos recursos
  • 21. ROA(Resource Oriented Architecture) <?xml version='1.0' encoding='UTF-8'?> <ListAllMyBucketsResult xmlns='http://s3.amazonaws.com/doc/2006-03-01/'> <Owner> <ID>c0363f7260f2f5fcf38d48039f4fb5cab21b060577817310be5170e7774aad70</ID> <DisplayName>leonardr28</DisplayName> </Owner> <Buckets> <Bucket> <Name>crummy.com</Name> <URI>https://s3.amazonaws.com/crummy.com</URI> <CreationDate>2006-10-26T18:46:45.000Z</CreationDate> </Bucket> </Buckets> </ListAllMyBucketsResult>