Top Banner
ReST you’re doing it wrong! Sergey Shishkin MT AG http://www.mt-ag.com http://shishkin.org @sshishkin
42

REST - You're Doing It Wrong

May 09, 2015

Download

Technology

Sergey Shishkin

Delivered during NRW Conf on 09.09.2011 in Wuppertal, Germany
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: REST - You're Doing It Wrong

ReSTyou’re doing it

wrong!Sergey ShishkinMT AG

http://www.mt-ag.comhttp://shishkin.org@sshishkin

Page 2: REST - You're Doing It Wrong

ReSTyou’re doing it

wrong!Sergey ShishkinMT AG

http://www.mt-ag.comhttp://shishkin.org@sshishkin

Page 3: REST - You're Doing It Wrong

A Tale of an Ice-Cream Maker

by Sebastien Lambla

Page 4: REST - You're Doing It Wrong

Architecture

of the web

Page 5: REST - You're Doing It Wrong

Loose Coupling

Page 6: REST - You're Doing It Wrong

Simplicity,Uniformity

Page 7: REST - You're Doing It Wrong

Scalability,Performance

Page 8: REST - You're Doing It Wrong

You MightNot Need It

Page 9: REST - You're Doing It Wrong

/products/books/can-haz-rest

/products ? title=can-haz-rest

/Y2FuLWhhei1yZXN0%3D

Which URI is RESTful?

Page 10: REST - You're Doing It Wrong

POST /REST.svc

<PlaceOrder> <Product> 1234 </Product> <Price> 19.90 </Price> <Qty> 2 </Qty></PlaceOrder>

Page 11: REST - You're Doing It Wrong

POST /REST.svc{ PlaceOrder: { Product: 1234, Price: 19.90, Quantity: 2 }}

Page 12: REST - You're Doing It Wrong

Richardson RESTMaturity Model

None

Page 13: REST - You're Doing It Wrong

GET /REST.svc ? op=PlaceOrder & product=1234 & qty=2

Page 14: REST - You're Doing It Wrong

URI Tunneling

Page 15: REST - You're Doing It Wrong

POST /Orders.svc ? product=1234 & qty=2

Page 16: REST - You're Doing It Wrong

GET idempotent, safe

POST non idempotent, unsafe

PUT idempotent, unsafe

DELETE idempotent, unsafe

HEAD idempotent, safe

OPTIONS idempotent, safe

Page 17: REST - You're Doing It Wrong

GET /Users/1234…PUT /Users/1234{ login: bob, … userpic: {…}, settings: {…}}

Page 18: REST - You're Doing It Wrong

Resourcesare notEntities

Page 19: REST - You're Doing It Wrong

CRUD

Page 20: REST - You're Doing It Wrong

CRUD

Page 21: REST - You're Doing It Wrong

GET /Profile/SettingsPOST /Profile/Settings

POST /Profile/Image

Page 22: REST - You're Doing It Wrong

URI Templates/products/{id}

Page 23: REST - You're Doing It Wrong

Richardson RESTMaturity Model

URI

None

Page 24: REST - You're Doing It Wrong

Versioning/api/v2

Page 25: REST - You're Doing It Wrong

GET /api

Accept: application/vnd.example+xml; version=2, application/xml

Page 26: REST - You're Doing It Wrong

Languages/de/product/1234/product/1234 ?

lang=fr

Page 27: REST - You're Doing It Wrong

GET /product/1234

Accept-Language: de

Page 28: REST - You're Doing It Wrong

Richardson RESTMaturity Model

HTTP

URI

None

Page 29: REST - You're Doing It Wrong

GET /Products/1234…Content-Type: application/json{ title: can-haz-rest, price: 19.99, …}

Page 30: REST - You're Doing It Wrong

Generic Media Types

Page 31: REST - You're Doing It Wrong

application/atom+xml;type=feed

application/vnd.example+json

Page 32: REST - You're Doing It Wrong

GET /Products/1234

{ title: can-haz-rest, price: 19.99,}

And What Now?

Page 33: REST - You're Doing It Wrong

{ title: “can-haz-rest”, links: [ { rel: “buy”, link: “Product/1234/buy” } ]}

Page 34: REST - You're Doing It Wrong

Richardson RESTMaturity Model

Hypermedia

HTTP

URI

None

Page 35: REST - You're Doing It Wrong

It’s all about resources,

Page 36: REST - You're Doing It Wrong

Representations,

Page 37: REST - You're Doing It Wrong

And Hypermedia!

Page 38: REST - You're Doing It Wrong

It’s All About Resources,

Representations, And

Hypermedia!

Page 39: REST - You're Doing It Wrong
Page 40: REST - You're Doing It Wrong

Beratung Projekte Schulungen

Application Lifecycle Design Entwicklung

Architektur SOA Cloud Computing

BalckeBalcke-Dürr-Allee 9, 40882 Ratingen www.mt-ag.com [email protected]

Page 41: REST - You're Doing It Wrong

Sergey Shishkinhttp://[email protected]@sshishkin

Page 42: REST - You're Doing It Wrong

Links & Credits• Richardson Maturity Model

– http://martinfowler.com/articles/richardsonMaturityModel.html• The Tale of the Ice-Cream Maker

– http://serialseb.blogspot.com/2009/06/fighting-for-rest-or-tale-of-ice-cream.html• REST in Practice

– http://restinpractice.com/• REST Content on InfoQ

– http://www.infoq.com/rest/

Images:– Web: http://www.flickr.com/photos/zzathras777/1546040168/– Mirrors: http://www.flickr.com/photos/coolmikeol/4156970741/– Rope: http://www.flickr.com/photos/visualpanic/2759322646/– Soup: http://www.flickr.com/photos/wallyg/562283586/– Ice-cream van: http://www.flickr.com/photos/estherase/516542355/– Ice-cream: http://www.flickr.com/photos/pinksherbet/3398923323/