Upgrade to Pro — share decks privately, control downloads, hide ads and more …

R.I.P.: REST in peace! A guide through RESTful ...

R.I.P.: REST in peace! A guide through RESTful services.

I did this presentation in the #9 Superplayer Hack Sessions.

Robson de Almeida

December 05, 2014
Tweet

More Decks by Robson de Almeida

Other Decks in Technology

Transcript

  1. WHAT REST DO NOT MEANS REST is NOT a framework

    REST is NOT a protocol REST is NOT SOA REST is NOT Client-Server Architecture REST is NOT a URI REST is NOT API
  2. ROY's WORK … Architectural Styles and the Design of Network-based

    Software Architectures REpresentational State Transfer is a architectural style for distributed hypermedia systems HTTP spec & Apache HTTP server
  3. STATELESS each request contains all of the information and cannot

    take advantage of any stored context on the server session state is kept entirely on the client
  4. RESOURCES the key abstraction of information in REST is a

    resource a resource IS NOT an API or ENDPOINT or METHOD
  5. RESOURCE IDENTIFIER Uniform Resource Identifier (URI) the key to access

    the resource { protocol } : { base uri } / { resource path }
  6. URI IS NOT an URL or URN but it covers

    it uniform resource locator uniform resource name
  7. NOUNS, NO VERBS Leave verbs for the HTTP verbs /playlists

    /playlists/10 /getAllPlaylists /getPlaylist?id=10 /get?type=playlist&id=10 good bad
  8. use POST, PUT and DELETE. also do not use GET

    when you HAVE no choice GET /subscriptions/171/cancel // bad PUT /subscriptions/171/cancel // bad but better ... HTTP GET SHOULD NOT ALTER THE STATE
  9. for successful requests, use 2xx status code. when the client

    is wrong, use 4xx status code. for unknown errors, use 5xx status code HTTP STATUS CODE