SlideShare a Scribd company logo
1 of 46
Download to read offline
@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 GoroutinesAdrian 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 MicroservicesAdrian Cockcroft
 
When Developers Operate and Operators Develop
When Developers Operate and Operators DevelopWhen Developers Operate and Operators Develop
When Developers Operate and Operators DevelopAdrian 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 OSCONAdrian 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 YorkAdrian Cockcroft
 
Innovation and Architecture
Innovation and ArchitectureInnovation and Architecture
Innovation and ArchitectureAdrian Cockcroft
 
Microservices Workshop - Craft Conference
Microservices Workshop - Craft ConferenceMicroservices Workshop - Craft Conference
Microservices Workshop - Craft ConferenceAdrian 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 TradeC4Media
 
Monitoring Challenges - Monitorama 2016 - Monitoringless
Monitoring Challenges - Monitorama 2016 - MonitoringlessMonitoring Challenges - Monitorama 2016 - Monitoringless
Monitoring Challenges - Monitorama 2016 - MonitoringlessAdrian Cockcroft
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleSudhir Tonse
 
Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016Microservices Workshop All Topics Deck 2016
Microservices Workshop All Topics Deck 2016Adrian Cockcroft
 
Evolution of Microservices - Craft Conference
Evolution of Microservices - Craft ConferenceEvolution of Microservices - Craft Conference
Evolution of Microservices - Craft ConferenceAdrian 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 MicroservicesAdrian 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

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 HydraMarkus 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 TitaniumJeroen 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 ArchitectureTom 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 WebTrotter Cashion
 
Couchbase presentation - by Patrick Heneise
Couchbase presentation - by Patrick HeneiseCouchbase presentation - by Patrick Heneise
Couchbase presentation - by Patrick Heneiseitnig
 
CSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and AnimationsCSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and AnimationsInayaili 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 SchnittstellenversionierungOPEN KNOWLEDGE GmbH
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spockGR8Conf
 
Forbes MongoNYC 2011
Forbes MongoNYC 2011Forbes MongoNYC 2011
Forbes MongoNYC 2011djdunlop
 
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’élastiqueNicolas 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 learnedMarcinStachniuk
 

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

Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

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