Chapter 7. REST, Resources, and Web Services

There are only two hard things in Computer Science: cache invalidation and naming things.

—Phil Karlton

The architectural principles of Representational State Transfer, or REST, have been taking the Rails world by storm. The idea behind REST has been around since Roy Fielding first described it in his 2000 doctoral dissertation. However, the ideas have only started to gain traction among Rails developers since David Heinemeier Hansson’s presentation of those ideas in 2006 and the subsequent adoption of RESTful principles in Rails 1.2. RESTful design is a new way of thinking about network architecture based on an observation of how the Web works.

What Is REST?

In short, REST is a unifying theory for how “distributed hypermedia” systems (primarily, the World Wide Web) are best organized and structured. The term was coined by Roy Fielding, coauthor of the HTTP specification, in his 2000 doctoral dissertation Architectural Styles and the Design of Network-Based Software Architectures.[63] The dissertation extracts a set of principles that are common to network architectures, based on an examination of the structure of the Web and the HTTP protocol. Starting with the “null style,” which is the absence of constraints on architecture, Fielding arrives at REST by placing a series of constraints on network architecture:

Client-Server

The client-server constraint imposes a separation of data storage from user interface and presentation. ...

Get Advanced Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.