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
Maturidade de APIs REST
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Brian Thomas Storti
October 17, 2014
Programming
290
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
230
Ruby object model e metaprogramação
brianstorti
5
310
Other Decks in Programming
See All in Programming
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
170
テーブルをDELETEした
yuzneri
0
140
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.8k
FDEが実現するAI駆動経営の現在地
gonta
2
280
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
460
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
160
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
170
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
490
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
260
Foundation Models frameworkで画像分析
ryodeveloper
1
610
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
140
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
210
Featured
See All Featured
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
270
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
sira's awesome portfolio website redesign presentation
elsirapls
0
320
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
ラッコキーワード サービス紹介資料
rakko
1
4.3M
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
25k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
The Curse of the Amulet
leimatthew05
2
14k
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