Intro
What is REST. Well technically REST stands for REpresntational State Transfer. REST is "an architectural style for distributed hypermedia systems". Um, OK. What does that even mean.
In plain english, REST is basically a set of guidelines for how a client + server should communicate and perform CRUD operations on a given resource.
Sometimes developers will talk about REST and they are talking about the overall principles and guidelines of REST, and sometimes you'll hear them talk about "RESTful". In this phraseology, their talking about being in compliance with the REST guidelines.
There was a dissertation given on this subject, and an excerpt describing REST,can be found here.
The main idea of REST is treating data on the server side as resources that can be CRUDed.
- CRUD : Create, Read, Update, Delete
So what we're talking about is a standardized, or generalized way that I can run a server, and anyone can say, create/read/update/delete a tweet. So anyone could have "full CRUD".
There is a huge amount of information on REST and CRUD online, but at this point in time, all we really need to understand is that we are going to we building different API's and APPs. But we are going to write all of our code in a "RESTful" manner, meaning it will be structured in an organized "standardized" way.
Project Overview
We are going to be building "comments" app with CRUD functionality, while maintaining a RESTful structure. And within this RESTful structure, there are a lot of ways we could actually structure our app, but here's what we're going to do. We're going to create a standard "syntax" for the routing of our API. We're going to use:
- Command
- GET /comments
- POST /comments
- GET /comments/:id
- PATCH /comments/:id
- DELETE /comments/:id
- Result
- List all comments
- Create a new comment
- GET one comment by id
- Update one comment by id
- Delete one comment by id
This will be our basic CRUD functionality. Now, we haven't learned how to build and access a database yet, (coming soon), but for now, we'll just set up an array we use in it's place.
Each element of our CRUD list is known as a route and developers usually give there routes names for a simple way of referring to each piece. We are going to do the same and use:
- Route Name
- Index
- New
- Show
- Update
- Destroy
- Command
- GET /comments
- POST /comments
- GET /comments/:id
- PATCH /comments/:id
- DELETE /comments/:id
- Result
- List all comments
- Create a new comment
- GET one comment by id
- Update one comment by id
- Delete one comment by id
So we've got our basic structure based on our RESTful, CRUD functionalities. Next we start building the app.
Back to Top