SlideShare a Scribd company logo
1 of 36
Download to read offline
REST in good!
André Goliath
[skip motivation, because REST]
REST is an abbreviation for…
a) Really Strange Topic
b) Relational Enterprise Scheme Trade
c) Representational State Transfer
d) ??? [use “send a comment”]
Representational State Transfer
Building Blocks: HTTP
(as far as this talk is concerned,
HTTP and HTTP/2 are the same)
URIs (Uniform Resource Identifier)
vs.
URLs (Uniform Resource Locator)
URLs locate resources
(“something that we can talk about
and that has ‘properties’ ”)
Verbs or methods
operate on resources
safe idempotent
GET
HEAD
OPTIONS
PUT
PATCH
DELETE
POST
HEAD and GET are the same,
except HEAD not sending the actual body
Browsers use OPTIONS to implement
Cross-Origin Resource Sharing (CORS)
OPTIONS and CORS Preflights
Use PUT to create or replace resources
if you know their exact URL
Otherwise, POST to the parent resource
Use PUT to replace a whole resource at once,
PUT operations must be idempotent!
Use PATCH to update partial data
We have a list of items, e.g. /messages
How do we get the number of all messages?
a) GET /messages and {…count: 5…}
b) GET /messages/count
c) GET /messages?count
d) ??? [use “send a comment”]
We have a list of items, e.g. /messages
How do we get the number of all messages?
> HEAD /messages
< …
< X-COUNT: 5
We GET the current temperature from
/house/livingroom/temp. But the sensor is
kinda unstable and needs to be power-cycled
from time to time. How would you do it?
a) POST /house/livingroom/temp/reset
b) PUT /house/livingroom/temp/reset
c) DELETE /house/livingroom/temp
d) ??? [use “send a comment”]
We GET the current temperature from
/house/livingroom/temp. But the sensor is
kinda unstable and needs to be power-cycled
from time to time. How would you do it?
> POST /house/scheduledTasks
> {
> time: ‘now’,
> action: ‘reset’,
> target: ‘livingroom/temp’
> }
HTTP is kinda bad
for long-running processes
No, you´re just
using it wrong
> POST /house/scheduledTasks
> {
> time: ‘in 2 hours’,
> action: ‘reset’,
> target: ‘livingroom/temp’
> }
> POST /house/scheduledTasks
> {
> time: ‘in 2 hours’,
> action: ‘reset’,
> target: ‘livingroom/temp’
> }
< HTTP/1.1 201 Created
< Location: https://…/scheduledTasks/7dhe9u
< HTTP/1.1 201 Created
< Location: https://…/scheduledTasks/7dhe9u
> GET /house/scheduledTasks/7dhe9u
< Cache-Control "max-age=3600, must-revalidate"
< {
< time: ‘2017-11-10T13:15:28+02:00’,
< action: ‘reset’,
< target: ‘livingroom/temp’,
< status: ‘scheduled’
< }
… two hours later …
> GET /house/scheduledTasks/7dhe9u
< {
< time: ‘2017-11-10T13:15:32+02:00’,
< action: ‘reset’,
< target: ‘livingroom/temp’,
< status: ‘done’,
< result: 200
< }
… one eternity later …
> GET /house/scheduledTasks/7dhe9u
< HTTP/1.1 404 Not Found
> GET /house/scheduledTasks/7dhe9u
< ???
a) 404 – Not Found
b) 202 - Accepted
c) 204 – No Content
d) 410 – Gone
e) ??? [use “send a comment”]
> GET /house/scheduledTasks/7dhe9u
< HTTP/1.1 410 Gone
> GET /house/scheduledTasks/1234567890
< HTTP/1.1 404 Not Found
HTTP
Status Codes
(just RTFM)
Why 404 has no ‘double meaning’
> GET /house/scheduledTasks/1234567890
< HTTP/1.1 404 Not Found
> GET /house/scheduledTasks/7dhe9u
< HTTP/1.1 410 Gone
> GET /house/scheduledTasks/8fks3k
< HTTP/1.1 200 OK
> GET /house/scheduledTasks/9edm4d
< HTTP/1.1 200 OK
Why 404 has no ‘double meaning’
> GET /houes/scheduledTasks/1234567890
< HTTP/1.1 404 Not Found
> GET /houes/scheduledTasks/7dhe9u
< HTTP/1.1 404 Not Found
> GET /houes/scheduledTasks/8fks3k
< HTTP/1.1 404 Not Found
> GET /houes/scheduledTasks/9edm4d
< HTTP/1.1 404 Not Found
Level Up your API!
The Richardson Maturity Model
https://martinfowler.com/articles/richardsonMaturityModel.html
Hypertext as the Engine of Application State
(HATEOAS)
https://github.com/farrelmr/introtospringdatarest
Thank You!
André Goliath
Lead Developer
andre.goliath@senacor.de

More Related Content

What's hot

Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
andymccurdy
 

What's hot (20)

ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4
 
Big data lambda architecture - Streaming Layer Hands On
Big data lambda architecture - Streaming Layer Hands OnBig data lambda architecture - Streaming Layer Hands On
Big data lambda architecture - Streaming Layer Hands On
 
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
CouchDB Day NYC 2017: Introduction to CouchDB 2.0CouchDB Day NYC 2017: Introduction to CouchDB 2.0
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
 
Altitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshopAltitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshop
 
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, EverAltitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
 
opentsdb in a real enviroment
opentsdb in a real enviromentopentsdb in a real enviroment
opentsdb in a real enviroment
 
Manage and Deploy your sites with Drush
Manage and Deploy your sites with DrushManage and Deploy your sites with Drush
Manage and Deploy your sites with Drush
 
ElasticSearch
ElasticSearchElasticSearch
ElasticSearch
 
Automating Workflows for Analytics Pipelines
Automating Workflows for Analytics PipelinesAutomating Workflows for Analytics Pipelines
Automating Workflows for Analytics Pipelines
 
The Puppet Master on the JVM - PuppetConf 2014
The Puppet Master on the JVM - PuppetConf 2014The Puppet Master on the JVM - PuppetConf 2014
The Puppet Master on the JVM - PuppetConf 2014
 
TDD of HTTP Clients With WebMock
TDD of HTTP Clients With WebMockTDD of HTTP Clients With WebMock
TDD of HTTP Clients With WebMock
 
Testing http calls with Webmock and VCR
Testing http calls with Webmock and VCRTesting http calls with Webmock and VCR
Testing http calls with Webmock and VCR
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날
 
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
 
Comparison nodejs frameworks using Polls API
Comparison nodejs frameworks using Polls APIComparison nodejs frameworks using Polls API
Comparison nodejs frameworks using Polls API
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Python Deployment with Fabric
Python Deployment with FabricPython Deployment with Fabric
Python Deployment with Fabric
 
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
 
Application Logging With The ELK Stack
Application Logging With The ELK StackApplication Logging With The ELK Stack
Application Logging With The ELK Stack
 

Similar to Rest in Good! - DevCon 2017

Interactive web. O rly?
Interactive web. O rly?Interactive web. O rly?
Interactive web. O rly?
timbc
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
Li Yi
 

Similar to Rest in Good! - DevCon 2017 (20)

Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
 
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Berlin...
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
 
Developing cacheable PHP applications - Confoo 2018
Developing cacheable PHP applications - Confoo 2018Developing cacheable PHP applications - Confoo 2018
Developing cacheable PHP applications - Confoo 2018
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
Getting started with DSpace 7 REST API
Getting started with DSpace 7 REST APIGetting started with DSpace 7 REST API
Getting started with DSpace 7 REST API
 
Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018Developing cacheable PHP applications - PHPLimburgBE 2018
Developing cacheable PHP applications - PHPLimburgBE 2018
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Interactive web. O rly?
Interactive web. O rly?Interactive web. O rly?
Interactive web. O rly?
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHP
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web Services
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Apache Traffic Server
Apache Traffic ServerApache Traffic Server
Apache Traffic Server
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
Core web vitals meten om je site sneller te maken - Combell Partner Day 2023
Core web vitals meten om je site sneller te maken - Combell Partner Day 2023Core web vitals meten om je site sneller te maken - Combell Partner Day 2023
Core web vitals meten om je site sneller te maken - Combell Partner Day 2023
 
Ellerslie User Group - ReST Presentation
Ellerslie User Group - ReST PresentationEllerslie User Group - ReST Presentation
Ellerslie User Group - ReST Presentation
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
 
Cqrs api v2
Cqrs api v2Cqrs api v2
Cqrs api v2
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Rest in Good! - DevCon 2017

  • 3. REST is an abbreviation for… a) Really Strange Topic b) Relational Enterprise Scheme Trade c) Representational State Transfer d) ??? [use “send a comment”]
  • 5.
  • 6. Building Blocks: HTTP (as far as this talk is concerned, HTTP and HTTP/2 are the same)
  • 7. URIs (Uniform Resource Identifier) vs. URLs (Uniform Resource Locator)
  • 8. URLs locate resources (“something that we can talk about and that has ‘properties’ ”)
  • 11. HEAD and GET are the same, except HEAD not sending the actual body
  • 12. Browsers use OPTIONS to implement Cross-Origin Resource Sharing (CORS)
  • 13. OPTIONS and CORS Preflights
  • 14. Use PUT to create or replace resources if you know their exact URL Otherwise, POST to the parent resource
  • 15. Use PUT to replace a whole resource at once, PUT operations must be idempotent! Use PATCH to update partial data
  • 16. We have a list of items, e.g. /messages How do we get the number of all messages? a) GET /messages and {…count: 5…} b) GET /messages/count c) GET /messages?count d) ??? [use “send a comment”]
  • 17. We have a list of items, e.g. /messages How do we get the number of all messages? > HEAD /messages < … < X-COUNT: 5
  • 18. We GET the current temperature from /house/livingroom/temp. But the sensor is kinda unstable and needs to be power-cycled from time to time. How would you do it? a) POST /house/livingroom/temp/reset b) PUT /house/livingroom/temp/reset c) DELETE /house/livingroom/temp d) ??? [use “send a comment”]
  • 19. We GET the current temperature from /house/livingroom/temp. But the sensor is kinda unstable and needs to be power-cycled from time to time. How would you do it? > POST /house/scheduledTasks > { > time: ‘now’, > action: ‘reset’, > target: ‘livingroom/temp’ > }
  • 20. HTTP is kinda bad for long-running processes No, you´re just using it wrong
  • 21. > POST /house/scheduledTasks > { > time: ‘in 2 hours’, > action: ‘reset’, > target: ‘livingroom/temp’ > }
  • 22. > POST /house/scheduledTasks > { > time: ‘in 2 hours’, > action: ‘reset’, > target: ‘livingroom/temp’ > } < HTTP/1.1 201 Created < Location: https://…/scheduledTasks/7dhe9u
  • 23. < HTTP/1.1 201 Created < Location: https://…/scheduledTasks/7dhe9u > GET /house/scheduledTasks/7dhe9u < Cache-Control "max-age=3600, must-revalidate" < { < time: ‘2017-11-10T13:15:28+02:00’, < action: ‘reset’, < target: ‘livingroom/temp’, < status: ‘scheduled’ < }
  • 24. … two hours later …
  • 25. > GET /house/scheduledTasks/7dhe9u < { < time: ‘2017-11-10T13:15:32+02:00’, < action: ‘reset’, < target: ‘livingroom/temp’, < status: ‘done’, < result: 200 < }
  • 26. … one eternity later …
  • 27. > GET /house/scheduledTasks/7dhe9u < HTTP/1.1 404 Not Found
  • 28. > GET /house/scheduledTasks/7dhe9u < ??? a) 404 – Not Found b) 202 - Accepted c) 204 – No Content d) 410 – Gone e) ??? [use “send a comment”]
  • 29. > GET /house/scheduledTasks/7dhe9u < HTTP/1.1 410 Gone > GET /house/scheduledTasks/1234567890 < HTTP/1.1 404 Not Found
  • 31. Why 404 has no ‘double meaning’ > GET /house/scheduledTasks/1234567890 < HTTP/1.1 404 Not Found > GET /house/scheduledTasks/7dhe9u < HTTP/1.1 410 Gone > GET /house/scheduledTasks/8fks3k < HTTP/1.1 200 OK > GET /house/scheduledTasks/9edm4d < HTTP/1.1 200 OK
  • 32. Why 404 has no ‘double meaning’ > GET /houes/scheduledTasks/1234567890 < HTTP/1.1 404 Not Found > GET /houes/scheduledTasks/7dhe9u < HTTP/1.1 404 Not Found > GET /houes/scheduledTasks/8fks3k < HTTP/1.1 404 Not Found > GET /houes/scheduledTasks/9edm4d < HTTP/1.1 404 Not Found
  • 34. The Richardson Maturity Model https://martinfowler.com/articles/richardsonMaturityModel.html
  • 35. Hypertext as the Engine of Application State (HATEOAS) https://github.com/farrelmr/introtospringdatarest
  • 36. Thank You! André Goliath Lead Developer andre.goliath@senacor.de