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
Links, forms and unicorns
Links, forms and unicorns
Links, forms and unicorns
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”}
Links, forms and unicorns
> 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…
Links, forms and unicorns
> 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”}
Links, forms and unicorns
> 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”}
Links, forms and unicorns
>   GET /malmo
<   200 OK
<   {“form”: {
<      “author”: null
<   }}
Oh no!

The agent in Malmo is a Mole! They
   have to be decommissioned!
Links, forms and unicorns
>   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.”}
Links, forms and unicorns
Links, forms and unicorns
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

Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 

Recently uploaded (20)

Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 

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
  • 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”}
  • 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…
  • 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”}
  • 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”}
  • 37. > GET /malmo < 200 OK < {“form”: { < “author”: null < }}
  • 38. Oh no! The agent in Malmo is a Mole! They have to be decommissioned!
  • 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.”}
  • 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