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

REST 101

REST 101

This is a short talk about some of the core REST concepts. It is not a technical talk as it focuses on the concepts instead any implementation details.

Avatar for Lucas Saldanha

Lucas Saldanha

April 21, 2017
Tweet

More Decks by Lucas Saldanha

Other Decks in Programming

Transcript

  1. Webservices • Expose some operations in a remote system •

    Enable infrastructure decoupling • Example: • Almost everything! • Different specifications and implementations
  2. Resources • Abstractions of a ‘thing’ in the system •

    E.g. User resource • Identified by one or more URIs • E.g. api.system.com/v1/users/1 • Differ from their representation • The same resource can have multiple representations • Representation • How the resources are manipulated • Typically XML or JSON
  3. REST concepts • Uniform Interface • Decouple the architecture •

    Elements: • HTTP verbs (GET, PUT, POST, DELETE, …) • URIs (resource naming) • HTTP responses (body + status code) • Stateless • Server doesn’t store any client state • Each request contains enough information to be processed • Any session state is kept in the client • Others (check this link)
  4. REST concepts • Safe operations • Read-only, don’t modify resources

    in the server • GET, HEAD, OPTIONS • Idempotency • PUT and DELETE operations should be implemented as idempotents • Executing the same request multiple times leaves the system in the same state as the first call (the response may be different though) • E.g. deleting a user vs. creating a user • Hypermedia • Finite-state machine • Resources and manipulations
  5. References • Roy Fielding doctoral dissertation that defines the basis

    of REST • http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm • Good website with a lot of material about the topic • http://www.restapitutorial.com • A post blog written by me about REST semantics • http://www.lucassaldanha.com/its-all-about-semantics/ • The REST Cook Book – has some nice material • http://restcookbook.com • Good post about REST • https://jcalcote.wordpress.com/2008/10/16/put-or-post-the-rest-of-the-story/