Get Some REST

Kevin Neyer
2 min readJun 17, 2020

When you or I think of rest, we view it as a state of inactivity — sleep, relaxing, etc. Heck, even your cat views it the same! After all, they did invent the cat nap.

However, in programming, specifically in the client-server internet relationship, it has an entirely different meaning. REST stands for representational state transfer. Essentially, this is an architectural model for how our internet browser(client) speaks with the internet(server).

Some background. Simply put, everything done on the web is the result of your browser communicating with the server. And, for every communication, there is a request and a response. For example, when typing in the web address of your favorite cat GIF website, your browser makes an http request to the server to get the information for the site, and in response, the server processes your request, finds and retrieves the appropriate information, and sends it back to your browser. Your browser then takes that info and translates it into the pretty, GIF-ing cats we all love. Great! But, what if I want to create a cat gif, or update my gif, or heaven forbid, delete it?

This is where our REST comes into play. REST takes our http requests(Get, Post, Put, Patch and Delete) and pairs it with our CRUD actions(Create, Read, Update, and Destroy) to create our RESTful routes to our urls. What this does is establish a natural flow for how we can work with our information to have it sent to and show up in the correct place.

Below is a list of our seven RESTful cat routes:

As you can see, Rails lays this out nicely for us. We have our path prefix, our http verbs, our URI/URL patterns, and our controller action. This is a lot of info! Using out RESTful conventions, we have access to all of these routes.

To see all of our cats, also know as our index, we would go to www.catgif.com/cats. To create a new cat, we’d make a GET request to ‘/cats/new’ and a POST request to ‘/cats’ once the information is submitted and created. These are just a few examples of the things we can do using REST.

In summary, RESTful conventions allow us to access and manipulate information by using a uniform and predefined set of operations, combining our CRUD actions in unison with respective HTTP requests for smooth, logical web applications. And, that’s rest we can all get behind!

--

--