Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Maturidade de APIs REST
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Brian Thomas Storti
October 17, 2014
Programming
300
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Maturidade de APIs REST
Brian Thomas Storti
October 17, 2014
More Decks by Brian Thomas Storti
See All by Brian Thomas Storti
Introdução ao Ruby
brianstorti
6
240
Ruby object model e metaprogramação
brianstorti
5
310
Other Decks in Programming
See All in Programming
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.6k
phperだってパンチカードでコーディングしたい
o0h
PRO
0
320
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
250
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
16k
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
130
パスワード再設定メールのURLについて知っておこう
uyuki234
0
150
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
4.9k
contenteditable と日本語入力に向き合う
colorful12
0
190
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
150
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
360
Featured
See All Featured
The browser strikes back
jonoalderson
0
1.8k
Between Models and Reality
mayunak
4
490
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
540
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
450
sira's awesome portfolio website redesign presentation
elsirapls
0
450
Into the Great Unknown - MozCon
thekraken
41
2.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
630
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Transcript
T h e D e v e l o p
e r s C o n f e r e n c e 2 0 1 4 MATURIDADE DE APIS REST Brian Storti Pedro Vereza
O QUE É REST ? 2
MODELO DE MATURIDADE Leonard Richardson, 2008 3
MODELO DE MATURIDADE 4
NIVEL 0 Uma URL e um método HTTP 5
NIVEL 0 ▫︎Um método HTTP ▫︎Uma URL ▫︎Tudo no payload
▫︎Independe do formato ▫︎SOAP 6 POST /tdcService HTTP/1.1 ! <openSlotRequest trilha = "arquitetura" data = "16-10-2014" duracao = "15"/> HTTP/1.1 200 OK ! <openSlotList> <slot start = "1655" end = "1710"> <trilha id = "arquitetura"/> </slot> </openSlotList>
NIVEL 1 Várias URLs e um método HTTP 7
NIVEL 1 ▫︎Um método HTTP ▫︎Várias URLs ▫︎URI Tunneling ▫︎HTTP
como camada de transporte 8 POST /getOpenSlots HTTP/1.1 ! <openSlotRequest trilha = "arquitetura" data = "16-10-2014" duracao = "15"/> POST /reserveSlot? trilha=arquitetura&date=16-10-2014 &nome=Maturidade-API-REST HTTP/1.1 HTTP/1.1 200 OK ! <openSlotResponse> <slot start = "1655" end = "1710"> <trilha id = "arquitetura"/> </slot> <openSlotResponse/>
NIVEL 2 Uso adequado do HTTP 9
NIVEL 2 ▫︎Várias URLs ▫︎Uso adequado dos métodos HTTP (RFC
2616) 10 GET /openSlots? trilha=arquitetura&data=16-10-2014 &duracao=15 HTTP/1.1 ! POST /reserveSlot? trilha=arquitetura&date=16-10-2014 &nome=Maturidade-API-REST HTTP/1.1 HTTP/1.1 200 OK <openSlotResponse> <slot start = "1655" end = "1710"> <trilha id = "arquitetura"/> </slot> <openSlotResponse/> HTTP/1.1 201 Created Location: /palestras/1234
11 NIVEL 3 Hypermedia
NIVEL 3 ▫︎Hypermedia ▫︎Hypermedia ▫︎Hypermedia 12 GET /openSlots HTTP/1.1 HTTP/1.1
200 OK <openSlotResponse> <link href="api.tdc.com/slot/1" rel = "reserve.slot" > <slot id=1 start="1655" end="1710"> <trilha id="arquitetura"/> </slot> <openSlotResponse/> GET api.tdc.com/ HTTP/1.1 200 OK <link href= "api.tdc.com/openSlots" rel= "open.slots"/> ! <link href= "api.tdc.com/slots" rel= "all.slots"/>
NETFLIX 13 <catalog_title_index> <title_index_item> <id>http://api-public.netflix.com/catalog/titles/movies/512381</id> <updated>1217404229</updated> <link href="http://api-public.netflix.com/catalog/people/20001977" rel="http://schemas.netflix.com/catalog/person.actor" title="Anna
Paquin"/> <link href="http://api-public.netflix.com/catalog/people/23599" rel="http://schemas.netflix.com/catalog/person.actor" title="Dana Delany"/> <link href="http://api-public.netflix.com/catalog/people/21741" rel="http://schemas.netflix.com/catalog/person.actor" title="Jeff Daniels"/> <release_year>1996</release_year> <link href="http://www.netflix.com/Movie/Fly_Away_Home/512381" rel="alternate" title="web page"/> <external_ids> <id rel="http://schemas.netflix.com/catalog/id.upc">0043396824393</id> <id rel="http://schemas.netflix.com/catalog/id.upc">0043396060463</id> </external_ids> </title_index_item> </catalog_title_index>
"Se o estado da aplicação não está sendo controlado por
hypermedia, então ela não pode ser chamada de RESTful. Ponto. Existe algum manual quebrado em algum lugar que precisa ser arrumado?” Roy Fielding, 2008 14
MUITO BONITO, MAS Por que não existem muitos serviços nível
3? 15
HAL+JSON 16
HAL+JSON 17
MODELO DE MATURIDADE 18 Uma URL, um método HTTP Várias
URLs, um método HTTP Uso adequado do HTTP Hypermedia
BOAS PRÁTICAS 19
CONHECERÁS TEUS VERBOS Saiba o que sua aplicação está dizendo
20
21 RFC 2616
MÉTODOS HTTP ▫︎GET - Leitura ▫︎DELETE - Remoção ▫︎POST -
Criação ▫︎PUT - Atualização 22
23 RFC 2616
"Se a URL requisitada não aponta para um recurso existente,
e esta URL pode ser definida como um novo recurso, o servidor pode criar o recurso nessa URL.” RFC 2616 sobre PUT 24
NÃO PERDERÁS TEMPO Cache 25
A requisição mais rápida é a requisição que não é
feita. 26
DIRÁS A VERDADE 27
STATUS CODE ▫︎1xx - Informação ▫︎2xx - Sucesso ▫︎3xx -
Redirecionamento ▫︎4xx - Erro do cliente ▫︎5xx - Erro do servidor 28
DIRÁS A VERDADE 29
ABRAÇARÁS A WEB 30
Brian Storti www.brianstorti.com
[email protected]
! Pedro Vereza www.pedrovereza.com
[email protected]
OBRIGADO