SlideShare a Scribd company logo
@serialseb
                 seb@serialseb.com
       http://codebetter.com/sebastienlambla/


Architect, trainer, speaker, developer, mayhem
                     inducer…
by the people, for the people
Web Development Done Right
Building Hypermedia APIs

Why links and forms will make your
        ReSTful API better
Links, forms and unicorns

Building Hypermedia APIs

Why links and forms will make your
        ReSTful API better
Your mission should you accept it…
• Go to Paris, give the agent your name and ask
  for his favourite monument
• Go to Brussels, tell the agent what you learnt,
  ask for their favourite food
• Go to Copenhagen, tell them what you learnt,
  ask for their favourite painter
• In Malmo, tell them what you learnt, receive
  the secret message
Your mission should you accept it…
• POST to /paris, expect {“status”: “ok”,
  “monument”: ??}
• POST to /brussels with {“monument”: ??},
  expect {“status”: “ok”, “food”: ??}
• POST to /copenhagen with {“food”: ??},
  expect {“status”:”ok”, “artist”: ??}
• POST to /malmo with {“artist”: ??}, expect
  {“status”: “ok”, “secret”: ??}
public void travel() {
  var response = _client
              .Post(“/paris”, new{name=“Pixie”})
              .Send();
  if (response.body.status == “ok”) {
    response = _client.Post(“/brussels”, new {
      monument=response.body.monument
    }).Send();
    // etc
  }
}
> POST /paris
> {“name”: “resty galore”}
Oh no!

The French don’t speak English!
         (who knew!)
> POST /paris
> {“name”: “resty galore”}

< 200 OK
< {“status”: “oui”, “monument”: “eiffel tower”}
public void travel() {
  var response = _client
              .Post(“/paris”, new{name=“Pixie”})
              .Send();
  if (response.status == 200) {
    response = _client.Post(“/brussels”, new {
      monument=response.body.monument
    }).Send();
    // etc
  }
}
> POST /paris
> {“name”: “resty galore”}

< 200 OK
< {“monument”: “eiffel tower”}
> POST /brussels
> {“monument”: “eiffel tower”}
Oh no!

The Belgium agent was captured and
    the message is now London!
> POST /brussels
> {“monument”: “eiffel tower”}

< 410 Gone somewhere colder
We could send an agent to
Brussels to warn Resty Galore…
> POST /brussels
> {“monument”: “eiffel tower”}

< 307 Redirect to London, quick!
Keeping agents in each location we need to
           redirect is expensive.

   Travelling for nothing is also expensive.

Or Resty Galore could start her journey with…
Keeping agents in each location we need to
           redirect is expensive.

Or Resty Galore could start her journey with…
> POST /paris
> {“name”: “resty galore”}

< 200 OK
< Link: </london>; rel=“next”
< {“monument”: “eiffel tower”}
public void travel() {
  var response = _client
              .Post(“/paris”, new{name=“Pixie”})
              .Send();
  if (response.status == 200) {
    response = _client.Post(response.links.next, new {
      monument = response.body.monument
    }).Send();
    // etc
  }
}
> POST /london
> {“monument”: “eiffel tower”}

< 418 I’m a teapot
<
<
<
<
<
> POST /london
> {“monument”: “eiffel tower”}

< 200 OK
< Link: </copenhagen>; rel=“next”
< {“food”: “Chicken Tikka Massala”}
> POST /copenhagen
> {“monument”: “eiffel tower”}
Oh no!

The Danish wants more security and
   require both the food and the
            monument!
> POST /copenhagen
> {“monument”: “eiffel tower”}

< 400 Bad request dudette
Forms
>   GET /copenhagen
<   200 OK
<   {“form”: {
<      “monument”: null,
<      “food”: null
<   }}

>   POST /copenhagen
>   {“monument”: “eiffel tower”,
>    “food”: “Chicken Tikka Massala”}
<   200 OK
<   Link: </malmo>; rel=“next”
<   {“author”: “hans christian andersen”}
>   GET /malmo
<   200 OK
<   {“form”: {
<      “author”: null
<   }}
Oh no!

The agent in Malmo is a Mole! They
   have to be decommissioned!
>   GET /malmo
<   200 OK
<   {“form”: {
<      “author”: null
<   }}

>   POST /malmo
>   {“author”: “hans christian andersen”}
<   200 OK
<   {“secret”: “not yet…”}
Forms with control data
>   GET /malmo
<   200 OK
<   {“form”: {
<      “method”: “DELETE”
<      “href”: “/malmo/mole”
<   }}

> DELETE /malmo/mole
> 200 OK
< {“secret”: “ReST is amazing.”}
We lowered coupling by…
• Respecting the Uniform Interface (status
  codes, verbs…)
• Introducing Links to navigate
• Introducing forms to know what to send
• Introducing control data in forms to enable a
  change in workflow with no change in the
  client code.
• OpenRasta - http://openrasta.org
• OpenWrap – http://openwrap.org

• Web linking -
  http://tools.ietf.org/html/rfc5988

More Related Content

Viewers also liked

Gophercon 2016 Communicating Sequential Goroutines
Gophercon 2016 Communicating Sequential GoroutinesGophercon 2016 Communicating Sequential Goroutines
Gophercon 2016 Communicating Sequential Goroutines
Adrian Cockcroft
 
Microxchg Analyzing Response Time Distributions for Microservices
Microxchg Analyzing Response Time Distributions for MicroservicesMicroxchg Analyzing Response Time Distributions for Microservices
Microxchg Analyzing Response Time Distributions for Microservices
Adrian Cockcroft
 
When Developers Operate and Operators Develop
When Developers Operate and Operators DevelopWhen Developers Operate and Operators Develop
When Developers Operate and Operators Develop
Adrian Cockcroft
 
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCONMicroservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
Adrian Cockcroft
 
Microservices: What's Missing - O'Reilly Software Architecture New York
Microservices: What's Missing - O'Reilly Software Architecture New YorkMicroservices: What's Missing - O'Reilly Software Architecture New York
Microservices: What's Missing - O'Reilly Software Architecture New York
Adrian Cockcroft
 
Innovation and Architecture
Innovation and ArchitectureInnovation and Architecture
Innovation and Architecture
Adrian Cockcroft
 
Microservices Workshop - Craft Conference
Microservices Workshop - Craft ConferenceMicroservices Workshop - Craft Conference
Microservices Workshop - Craft Conference
Adrian Cockcroft
 
In Search of Segmentation
In Search of SegmentationIn Search of Segmentation
In Search of Segmentation
Adrian Cockcroft
 
Scalable Microservices at Netflix. Challenges and Tools of the Trade
Scalable Microservices at Netflix. Challenges and Tools of the TradeScalable Microservices at Netflix. Challenges and Tools of the Trade
Scalable Microservices at Netflix. Challenges and Tools of the Trade
C4Media
 
Monitoring Challenges - Monitorama 2016 - Monitoringless
Monitoring Challenges - Monitorama 2016 - MonitoringlessMonitoring Challenges - Monitorama 2016 - Monitoringless
Monitoring Challenges - Monitorama 2016 - Monitoringless
Adrian Cockcroft
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scale
Sudhir Tonse
 
Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016
Adrian Cockcroft
 
Evolution of Microservices - Craft Conference
Evolution of Microservices - Craft ConferenceEvolution of Microservices - Craft Conference
Evolution of Microservices - Craft Conference
Adrian Cockcroft
 
Dockercon State of the Art in Microservices
Dockercon State of the Art in MicroservicesDockercon State of the Art in Microservices
Dockercon State of the Art in Microservices
Adrian Cockcroft
 

Viewers also liked (14)

Gophercon 2016 Communicating Sequential Goroutines
Gophercon 2016 Communicating Sequential GoroutinesGophercon 2016 Communicating Sequential Goroutines
Gophercon 2016 Communicating Sequential Goroutines
 
Microxchg Analyzing Response Time Distributions for Microservices
Microxchg Analyzing Response Time Distributions for MicroservicesMicroxchg Analyzing Response Time Distributions for Microservices
Microxchg Analyzing Response Time Distributions for Microservices
 
When Developers Operate and Operators Develop
When Developers Operate and Operators DevelopWhen Developers Operate and Operators Develop
When Developers Operate and Operators Develop
 
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCONMicroservices Application Tracing Standards and Simulators - Adrians at OSCON
Microservices Application Tracing Standards and Simulators - Adrians at OSCON
 
Microservices: What's Missing - O'Reilly Software Architecture New York
Microservices: What's Missing - O'Reilly Software Architecture New YorkMicroservices: What's Missing - O'Reilly Software Architecture New York
Microservices: What's Missing - O'Reilly Software Architecture New York
 
Innovation and Architecture
Innovation and ArchitectureInnovation and Architecture
Innovation and Architecture
 
Microservices Workshop - Craft Conference
Microservices Workshop - Craft ConferenceMicroservices Workshop - Craft Conference
Microservices Workshop - Craft Conference
 
In Search of Segmentation
In Search of SegmentationIn Search of Segmentation
In Search of Segmentation
 
Scalable Microservices at Netflix. Challenges and Tools of the Trade
Scalable Microservices at Netflix. Challenges and Tools of the TradeScalable Microservices at Netflix. Challenges and Tools of the Trade
Scalable Microservices at Netflix. Challenges and Tools of the Trade
 
Monitoring Challenges - Monitorama 2016 - Monitoringless
Monitoring Challenges - Monitorama 2016 - MonitoringlessMonitoring Challenges - Monitorama 2016 - Monitoringless
Monitoring Challenges - Monitorama 2016 - Monitoringless
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scale
 
Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016
 
Evolution of Microservices - Craft Conference
Evolution of Microservices - Craft ConferenceEvolution of Microservices - Craft Conference
Evolution of Microservices - Craft Conference
 
Dockercon State of the Art in Microservices
Dockercon State of the Art in MicroservicesDockercon State of the Art in Microservices
Dockercon State of the Art in Microservices
 

Similar to Links, forms and unicorns

JSON and the APInauts
JSON and the APInautsJSON and the APInauts
JSON and the APInauts
Wynn Netherland
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and Hydra
Markus Lanthaler
 
Teaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in TitaniumTeaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in Titanium
Jeroen van Dijk
 
Aesthetics and the Beauty of an Architecture
Aesthetics and the Beauty of an ArchitectureAesthetics and the Beauty of an Architecture
Aesthetics and the Beauty of an Architecture
Tom Scott
 
Eve - REST API for Humans™
Eve - REST API for Humans™Eve - REST API for Humans™
Eve - REST API for Humans™
Nicola Iarocci
 
Chloe and the Realtime Web
Chloe and the Realtime WebChloe and the Realtime Web
Chloe and the Realtime Web
Trotter Cashion
 
Couchbase presentation - by Patrick Heneise
Couchbase presentation - by Patrick HeneiseCouchbase presentation - by Patrick Heneise
Couchbase presentation - by Patrick Heneise
itnig
 
CSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and AnimationsCSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and Animations
Inayaili León
 
Vorstellung von VeRST, einem Framework zur Schnittstellenversionierung
Vorstellung von VeRST, einem Framework zur SchnittstellenversionierungVorstellung von VeRST, einem Framework zur Schnittstellenversionierung
Vorstellung von VeRST, einem Framework zur Schnittstellenversionierung
OPEN KNOWLEDGE GmbH
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spock
GR8Conf
 
Forbes MongoNYC 2011
Forbes MongoNYC 2011Forbes MongoNYC 2011
Forbes MongoNYC 2011
djdunlop
 
Consul ou comment bien tirer sur l’élastique
 Consul ou comment bien tirer sur l’élastique Consul ou comment bien tirer sur l’élastique
Consul ou comment bien tirer sur l’élastique
Nicolas Ledez
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learned
MarcinStachniuk
 

Similar to Links, forms and unicorns (16)

JSON and the APInauts
JSON and the APInautsJSON and the APInauts
JSON and the APInauts
 
Api vortrag
Api vortragApi vortrag
Api vortrag
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and Hydra
 
Teaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in TitaniumTeaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in Titanium
 
Aesthetics and the Beauty of an Architecture
Aesthetics and the Beauty of an ArchitectureAesthetics and the Beauty of an Architecture
Aesthetics and the Beauty of an Architecture
 
Eve - REST API for Humans™
Eve - REST API for Humans™Eve - REST API for Humans™
Eve - REST API for Humans™
 
Chloe and the Realtime Web
Chloe and the Realtime WebChloe and the Realtime Web
Chloe and the Realtime Web
 
Couchbase presentation - by Patrick Heneise
Couchbase presentation - by Patrick HeneiseCouchbase presentation - by Patrick Heneise
Couchbase presentation - by Patrick Heneise
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
CSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and AnimationsCSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and Animations
 
Vorstellung von VeRST, einem Framework zur Schnittstellenversionierung
Vorstellung von VeRST, einem Framework zur SchnittstellenversionierungVorstellung von VeRST, einem Framework zur Schnittstellenversionierung
Vorstellung von VeRST, einem Framework zur Schnittstellenversionierung
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spock
 
Forbes MongoNYC 2011
Forbes MongoNYC 2011Forbes MongoNYC 2011
Forbes MongoNYC 2011
 
Consul ou comment bien tirer sur l’élastique
 Consul ou comment bien tirer sur l’élastique Consul ou comment bien tirer sur l’élastique
Consul ou comment bien tirer sur l’élastique
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learned
 

Recently uploaded

Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 

Recently uploaded (20)

Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 

Links, forms and unicorns

  • 1. @serialseb seb@serialseb.com http://codebetter.com/sebastienlambla/ Architect, trainer, speaker, developer, mayhem inducer…
  • 2. by the people, for the people
  • 4. Building Hypermedia APIs Why links and forms will make your ReSTful API better
  • 5. Links, forms and unicorns Building Hypermedia APIs Why links and forms will make your ReSTful API better
  • 6.
  • 7.
  • 8.
  • 9. Your mission should you accept it… • Go to Paris, give the agent your name and ask for his favourite monument • Go to Brussels, tell the agent what you learnt, ask for their favourite food • Go to Copenhagen, tell them what you learnt, ask for their favourite painter • In Malmo, tell them what you learnt, receive the secret message
  • 10. Your mission should you accept it… • POST to /paris, expect {“status”: “ok”, “monument”: ??} • POST to /brussels with {“monument”: ??}, expect {“status”: “ok”, “food”: ??} • POST to /copenhagen with {“food”: ??}, expect {“status”:”ok”, “artist”: ??} • POST to /malmo with {“artist”: ??}, expect {“status”: “ok”, “secret”: ??}
  • 11. public void travel() { var response = _client .Post(“/paris”, new{name=“Pixie”}) .Send(); if (response.body.status == “ok”) { response = _client.Post(“/brussels”, new { monument=response.body.monument }).Send(); // etc } }
  • 12. > POST /paris > {“name”: “resty galore”}
  • 13. Oh no! The French don’t speak English! (who knew!)
  • 14. > POST /paris > {“name”: “resty galore”} < 200 OK < {“status”: “oui”, “monument”: “eiffel tower”}
  • 15. public void travel() { var response = _client .Post(“/paris”, new{name=“Pixie”}) .Send(); if (response.status == 200) { response = _client.Post(“/brussels”, new { monument=response.body.monument }).Send(); // etc } }
  • 16. > POST /paris > {“name”: “resty galore”} < 200 OK < {“monument”: “eiffel tower”}
  • 17.
  • 18. > POST /brussels > {“monument”: “eiffel tower”}
  • 19. Oh no! The Belgium agent was captured and the message is now London!
  • 20. > POST /brussels > {“monument”: “eiffel tower”} < 410 Gone somewhere colder
  • 21. We could send an agent to Brussels to warn Resty Galore…
  • 22. > POST /brussels > {“monument”: “eiffel tower”} < 307 Redirect to London, quick!
  • 23. Keeping agents in each location we need to redirect is expensive. Travelling for nothing is also expensive. Or Resty Galore could start her journey with…
  • 24. Keeping agents in each location we need to redirect is expensive. Or Resty Galore could start her journey with…
  • 25.
  • 26. > POST /paris > {“name”: “resty galore”} < 200 OK < Link: </london>; rel=“next” < {“monument”: “eiffel tower”}
  • 27. public void travel() { var response = _client .Post(“/paris”, new{name=“Pixie”}) .Send(); if (response.status == 200) { response = _client.Post(response.links.next, new { monument = response.body.monument }).Send(); // etc } }
  • 28. > POST /london > {“monument”: “eiffel tower”} < 418 I’m a teapot < < < < <
  • 29. > POST /london > {“monument”: “eiffel tower”} < 200 OK < Link: </copenhagen>; rel=“next” < {“food”: “Chicken Tikka Massala”}
  • 30.
  • 31. > POST /copenhagen > {“monument”: “eiffel tower”}
  • 32. Oh no! The Danish wants more security and require both the food and the monument!
  • 33. > POST /copenhagen > {“monument”: “eiffel tower”} < 400 Bad request dudette
  • 34. Forms
  • 35. > GET /copenhagen < 200 OK < {“form”: { < “monument”: null, < “food”: null < }} > POST /copenhagen > {“monument”: “eiffel tower”, > “food”: “Chicken Tikka Massala”} < 200 OK < Link: </malmo>; rel=“next” < {“author”: “hans christian andersen”}
  • 36.
  • 37. > GET /malmo < 200 OK < {“form”: { < “author”: null < }}
  • 38. Oh no! The agent in Malmo is a Mole! They have to be decommissioned!
  • 39.
  • 40. > GET /malmo < 200 OK < {“form”: { < “author”: null < }} > POST /malmo > {“author”: “hans christian andersen”} < 200 OK < {“secret”: “not yet…”}
  • 42. > GET /malmo < 200 OK < {“form”: { < “method”: “DELETE” < “href”: “/malmo/mole” < }} > DELETE /malmo/mole > 200 OK < {“secret”: “ReST is amazing.”}
  • 43.
  • 44.
  • 45. We lowered coupling by… • Respecting the Uniform Interface (status codes, verbs…) • Introducing Links to navigate • Introducing forms to know what to send • Introducing control data in forms to enable a change in workflow with no change in the client code.
  • 46. • OpenRasta - http://openrasta.org • OpenWrap – http://openwrap.org • Web linking - http://tools.ietf.org/html/rfc5988