Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hypermedia APIs with Webmachine and ROAR
Search
Larry Staton Jr.
November 15, 2012
Technology
550
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Hypermedia APIs with Webmachine and ROAR
Building hypermedia APIs with Webmachine and ROAR
Larry Staton Jr.
November 15, 2012
More Decks by Larry Staton Jr.
See All by Larry Staton Jr.
Object-Oriented Programming Basics with Smalltalk
statonjr
0
560
A Tale of Two Teams
statonjr
0
61
Hypermedia with Transit
statonjr
0
90
Hazel & Keyboard Maestro: A Perfect Mac Marriage
statonjr
1
700
Zooming Out
statonjr
0
70
HTTP 101
statonjr
1
290
PUT /time
statonjr
1
85
Other Decks in Technology
See All in Technology
OpenTelemetryにおけるGoのゼロコード・コンパイル時計装について #fukuokago
quiver
0
160
「顧客の声を聞かなければ何も始まらない」 ── 顧客の声から生まれた『AI返信補助機能』の開発プロセス / AICon2026_shikata_imai
rakus_dev
0
220
AIとハーネスで育てるトランスコンパイラ / 20260722 Yasushi Katayama
shift_evolve
PRO
0
380
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
530
壊して学ぶAWS CDK: そのcdk deployで消えるもの、残るもの
k_adachi_01
1
440
「早く出す」より「事業に効く」 ── 顧客の業務サイクルから逆算するAI時代の二重ループ開発と「変化の設計者」 / devsumi2026
rakus_dev
1
490
AIコード生成×サプライチェーン攻撃 — PHPが直面する“二重の信頼問題
shinyasaita
0
330
Claude Code公式skillで 自分の仕事を少しずつ手放そう!(Claude Code開発ノウハウ大公開スペシャル by クラスメソッド)
kaym
1
530
Multicaで30個のミニプロジェクトをAIエージェント運用して見えてきたこと
eiei114
0
540
ガバナンスの「ちょうどいい落とし所」を探れ!開発スピードを妨げない運用判断の勘所 / SRE NEXT 2026
genda
1
270
Genie Ontologyは銀の弾丸かを考える / Is Genie Ontology a Silver Bullet?
nttcom
0
420
Playwright × AI Agent でE2Eテストはどう変わるか AI駆動テストの可能性と実用検証の結果
taiga7543
1
660
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
360
Into the Great Unknown - MozCon
thekraken
41
2.6k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
230
AI: The stuff that nobody shows you
jnunemaker
PRO
8
840
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Designing Experiences People Love
moore
143
24k
Building an army of robots
kneath
306
46k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Transcript
Hypermedia APIs Hypermedia APIs Webmachine & ROAR 1 Larry Staton
Jr. : @statonjr 1 Wednesday, 14 November 12
Hypermedia APIs Assumptions 2 2 Wednesday, 14 November 12
Hypermedia APIs REST 3 3 Wednesday, 14 November 12
Hypermedia APIs 4 Constraint Promotes Tradeoff client-server UI Portability Simplified
server stateless Scalability Reliability Efficiency non-shared caching Reduced latency Efficiency Scalability Reliability uniform interface Independent Evolution Decoupled implementation Efficiency layered system Scalability Simplified clients Higher Latency code-on-demand Extensibility Simplified clients Visibility 4 Wednesday, 14 November 12
Hypermedia APIs 5 Uniform Interface 5 Wednesday, 14 November 12
Hypermedia APIs HTTP 6 6 Wednesday, 14 November 12
Hypermedia APIs 7 Constraint Promotes Tradeoff client-server UI Portability Simplified
server stateless Scalability Reliability Efficiency non-shared caching Reduced latency Efficiency Scalability Reliability uniform interface Independent Evolution Decoupled implementation Efficiency layered system Scalability Simplified clients Higher Latency code-on-demand Extensibility Simplified clients Visibility 7 Wednesday, 14 November 12
Hypermedia APIs “REST APIs must be hypertext-driven” 8 — Fielding,
2009! 8 Wednesday, 14 November 12
Hypermedia APIs 9 Richardson Maturity Model 9 Wednesday, 14 November
12
Hypermedia APIs Hypermedia 10 10 Wednesday, 14 November 12
Hypermedia APIs Media Types 11 11 Wednesday, 14 November 12
Hypermedia APIs 12 Media Type Hypermedia? text/html application/atom+xml application/json application/hal+json
12 Wednesday, 14 November 12
Hypermedia APIs HTTP 13 13 Wednesday, 14 November 12
Hypermedia APIs 14 14 Wednesday, 14 November 12
Hypermedia APIs Webmachine 15 15 Wednesday, 14 November 12
Hypermedia APIs Resources 16 16 Wednesday, 14 November 12
Hypermedia APIs 17 class HomeResource < Webmachine::Resource def allowed_methods %W[GET]
end def expires Time.now + 2.weeks end def languages_provided [“en-us”] end end 17 Wednesday, 14 November 12
Hypermedia APIs 18 allow_missing_post? allowed_methods base_uri charsets_provided content_types_accepted content_types_provided create_path
delete_completed? delete_resource encodings_provided expires finish_request forbidden generate_etag is_authorized? is_conflict? known_content_type? known_methods language_chosen languages_provided last_modified malformed_request? moved_permanently? moved_temporarily? multiple_choices? options post_is_create? previously_existed? process_post resource_exists? service_available? uri_too_long? valid_content_headers? valid_entity_length? validate_content_checksum variances Callbacks 18 Wednesday, 14 November 12
Hypermedia APIs 19 Webmachine::Application.new do |app| app.routes do add [],
HomeResource end end 19 Wednesday, 14 November 12
Hypermedia APIs Representation 20 20 Wednesday, 14 November 12
Hypermedia APIs HTML 21 21 Wednesday, 14 November 12
Hypermedia APIs 22 <!DOCTYPE html> <html lang=”en”> <body> <a href=”...”
rel=”../vehicles”>Vehicles</a> </body> </html> Example HTML Representation 22 Wednesday, 14 November 12
Hypermedia APIs 23 class HomeResource < Webmachine::Resource … def content_types_provided
[[‘text/html’, :to_html]] end def to_html template = Slim::Template.new(“home_representer.slim”) template.render end end 23 Wednesday, 14 November 12
Hypermedia APIs HAL+JSON 24 24 Wednesday, 14 November 12
Hypermedia APIs 25 { “_links”: { “self”: { “href”: “.../api”
}, “vehicles”: { “href”: “.../vehicles” } } } Example HAL+JSON Representation 25 Wednesday, 14 November 12
Hypermedia APIs ROAR 26 26 Wednesday, 14 November 12
Hypermedia APIs 27 module HomeRepresenter include Roar::Representer::JSON include Roar::Representer::JSON::HAL include
Roar::Representer::Feature::Hypermedia link :self do "/api" end link :vehicles do ".../vehicles" end end 27 Wednesday, 14 November 12
Hypermedia APIs 28 class HomeResource < Webmachine::Resource … def content_types_provided
[[‘application/hal+json’, :to_hal]] end def to_hal home = Object.new.extend(HomeRepresenter) home.to_json end end 28 Wednesday, 14 November 12
Hypermedia APIs Next Steps 29 29 Wednesday, 14 November 12
Hypermedia APIs Conclusion 30 30 Wednesday, 14 November 12
Hypermedia APIs Questions? 31 31 Wednesday, 14 November 12
Hypermedia APIs Additional Resources 32 seancribbs/webmachine-ruby apotonick/roar Jon Moore’s 2010
Oredev talk Steve Klabnik: “Designing Hypermedia APIs” Mike Amundsen: “Building Hypermedia APIs” Webber/Robinson: “REST in Practice” RESTFest 32 Wednesday, 14 November 12