The Road to REST One link at a time Rickard berg, Neo Technology - - PowerPoint PPT Presentation

the road to rest
SMART_READER_LITE
LIVE PREVIEW

The Road to REST One link at a time Rickard berg, Neo Technology - - PowerPoint PPT Presentation

The Road to REST One link at a time Rickard berg, Neo Technology QCon code: 7817 How it all began The Mission A fork in the road RMI? SOAP? REST? Exploring Richardson Maturity model Level 0 SOAP , XML RPC, POX Single URI Level 1 URI


slide-1
SLIDE 1

One link at a time Rickard Öberg, Neo Technology QCon code: 7817

The Road to REST

slide-2
SLIDE 2

How it all began

slide-3
SLIDE 3

The Mission

slide-4
SLIDE 4

A fork in the road

RMI? SOAP? REST?

slide-5
SLIDE 5

Exploring

slide-6
SLIDE 6

Richardson Maturity model

Level 0 SOAP , XML RPC, POX – Single URI Level 1 URI Tunnelling – Many URIs, Single verb Level 2 Many URIs, many verbs CRUD services (e.g. Amazon S3) Level 3 Level 2 + Hypermedia – RESTful Services

slide-7
SLIDE 7

REST to the rescue!

“Representational State Transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web”

slide-8
SLIDE 8

Guidelines

Client–server Stateless Cacheable Layered system Uniform interface


 http://en.wikipedia.org/wiki/Representational_State_Transfer#Constraints

slide-9
SLIDE 9

More guidelines

Identification of resources Manipulation of resources through these representations Self-descriptive messages Hypermedia As The Engine Of Application State (HATEOAS)

slide-10
SLIDE 10

The narrow road

slide-11
SLIDE 11

What shall we expose?

Client Server Data

slide-12
SLIDE 12

What shall we expose?

Client Server Domain model

slide-13
SLIDE 13

How?

Servlets? JAX-RS? Restlet www.restlet.org

slide-14
SLIDE 14

What the...?

/users/rickard/changepassword /users/rickard/resetpassword

slide-15
SLIDE 15

Where is HATEOAS?!?

“The next control state of an application resides in the representation of the first requested resource, … The application state is controlled and stored by the user agent … anticipate changes to that state (e.g., link maps and prefetching of representations) … The model application is therefore an engine that moves from one state to the next by examining and choosing from among the alternative state transitions in the current set of representations.” - Roy Fielding

slide-16
SLIDE 16

What now?!?

slide-17
SLIDE 17

One step at a time

slide-18
SLIDE 18

What shall we expose?

Client Server Use cases

slide-19
SLIDE 19

From the user perspective

/account/changepassword /administration/server/users/rickard/resetpassword

slide-20
SLIDE 20

Who can do what?

/workspace/cases/<123>/ /administrator/... /overview/...

slide-21
SLIDE 21

Follow the named link

REST API Links Link Query Command

slide-22
SLIDE 22

Application flow

GET ..../index GET <link with rel="possiblelabels"> addlabel?id=1234, rel=addlabel, "Urgent!" POST the link

slide-23
SLIDE 23

Link checking

What can the user do? Check for links!

slide-24
SLIDE 24

Wohoo!

slide-25
SLIDE 25

Versioning

HATEOAS helps Exposing use cases helps Send header

  • Ex. X-STREAMFLOW-API: 1.2

Client libraries

slide-26
SLIDE 26

Performance

Exposing use cases really helps Use e.g. GQL for table queries Client decides columns and filtering from fixed set

slide-27
SLIDE 27

TL;DL

A Good REST API is like an ugly website RESTful clients should follow links and submit forms

slide-28
SLIDE 28

Q & A

rickard.oberg@neotechnology.com @rickardoberg http://rickardoberg.wordpress.com http://qi4j.org