SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Nick „The German“ Sutterer OMG, he's on the twitter, finally! @apotonick Hypermedia for y'all!
45 minutes... ,[object Object]
Hypermedia
ROAR
„ architectural style for distributed hypermedia systems“ Roy Fielding's dissertation, chapter 5, line 1
require  'rest' class  Application include  Restful end
GET  http://nick/state {„status“  : „tired“, „ status-fr“: „fatigue“}
Resource Unique URL http://wines/red/1 Uniform Interface GET POST PUT ... Represen- tation
GET  http://wines/red/1 {„color“: „red“, „ alc“: 12.8, … }
POST http://wines/ {„color“: „red“, „ alc“: 12.8 } http://wines/red/1 {„id“:  1, „ color“: „red“, „ alc“:  12.8, }
GET  http://wines/red/1 Content-Type: app/wine+json <body>
JSON Representations == Documents
GET:  show POST: create PUT:  update ... REST is CRUD is not REST!
Hypermedia? <a href=“ http://wine.fr/buy “> Buy good wine! </a>
<wine> <id>1</id> <color>red</color> <link rel=“ buy “ href=“ http://wine/buy/1 “ />
Order Article User Variant Size Role Client Address Shipping Authenti- cation Price
Order Article User Variant Size Role Client Address Shipping Authenti- cation Price
„ Tab“ =  Ordered drinks  per  Table RESTaurant
RESTaurant.tabs.add(table_3) POST  http://tabs
{„tab“:  { „ table“: 3 , „ drinks“: [], ... }} ? ! POST  http://tabs {„tab“: {„table“: 3}} REST client!
{„tab“: { „ id“:  42 „ table“:  3, „ drinks“: [], „ links“:  [ {„rel“  => „self“, „ href“ => „http://tabs/42“}, {„rel“  => „order“, „ href“ => „http://tabs/42/order/{name}“}  {„rel“  => „pay“, „ href“ => „http://tabs/42/pay“} ] }} Hypermedia!
{„ rel “  => „pay“, „ href “ => „http://tabs/42/pay“}
<tab> <id>42</id> <table>3</table> <drinks /> <link rel=„self“ href=„ http://tabs/42 “ /> <link rel =„order“  href=„ http://tabs/42 /order/{name}“ /> <link rel=„pay“  href=„ http://tabs/42 /pay“ /> </tab>
{„tab“: { „ id“:  42 „ table“:  3, „ drinks“: [], „ links“:  [ {„rel“  => „self“, „ href“ => „http://tabs/42“}, {„rel“  => „order“, „ href“ => „http://tabs/42/order/{name}“}  {„rel“  => „pay“, „ href“ => „http://tabs/42/pay“} ] }}
RESTaurant. tab(42). order(11) 1. look for rel=“order“ 2. extract href 3. expand URL template 4. POST
{„tab“: { „ id“:  42 „ table“:  3, „ drinks“: [], „ links“:  [ {„rel“  => „self“, „ href“ => „http://tabs/42“}, { „rel“  => „order“, „ href“ => „http://tabs/42/order/{name}“ }  {„rel“  => „pay“, „ href“ => „http://tabs/42/pay“} ] }}
http://tabs/42/order/bordeaux
? ! POST  http://tabs/42/order/bordeaux {„tab“: { „ id“:  42 „ table“:  3, „ drinks“:  [bordeaux] ,
http://tabs/42/order/bordeaux ,[object Object]
NO guessing
Just following links
Code!
{„tab“:  { „ table“: 3 , „ drinks“: [11], „ links“: [ {„rel“: „self“, }} ? ! GET  http://tabs /42
class TabRepresenter < Roar::Representer::JSON property  :id, :table collection  :drinks link  :self do tab_url(represented) end link  :order do order_url(represented) end ...
TabRepresenter. from_model (@tab). serialize # => {„tab“:  { „ id“: 42 „ table“: 3 , „ drinks“: [11], „ links“: [ {„rel“:  „self“, „ href“: „ http://tabs/42 “} ...
{„tab“:  { „ table“: 3 , „ drinks“: [11], „ links“: [ ... ? ! POST  http://tabs {„tab“: {„table“: 3, „ drinks“: 11}}
TabRepresenter. deserialize (json_body). to_nested_attributes # => {:table => 3, :drink_ids => [11]} TableOrder.create(attrs)

Weitere ähnliche Inhalte

Empfohlen

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Empfohlen (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

CRUD Is Not REST! Hypermedia For Y'All!

Hinweis der Redaktion

  1. Have great user interfaces Bild von facebook einblenden
  2. Architectural style Up to you as architect No gem
  3. Have great user interfaces Bild von facebook einblenden
  4. People usually write a huge app with uncountable dependencies. In the last project
  5. Have great user interfaces Bild von facebook einblenden