Miscellaneous Tech Topics (eg. REST vs SOAP, SOLID) Flashcards

1
Q

Describe the different possible commands over a REST interface and how they work.

A

REST API is one of the most common if not the most common architectural design patterns for a modern web application and it’s corresponding back-end. In a REST API design, the back-end displays an interface called a REST interface over HTTP protocol that a client (basically, a browser) can pass information to and use, this is usually done in Javascript. They can pass the information in a variety of ways, either thru the URL itself which is known as a query string, or through sending JSON or XML data directly through HTTP (done in a variety of ways using javascript). Data will be sent from the back-end server back to this front-end application again thru HTTP, containing the results for what was asked. Then the client-side browser can parse this information and use it accordingly.

Example: We can use a library of books as the example for a REST API.

GET  /books/ .... collection.fetch();
POST /books/ .... collection.create();
GET  /books/1 ... model.fetch();
PUT  /books/1 ... model.save();
DEL  /books/1 ... model.destroy();

The changes the user makes on the front-end website in their browserreflect which REST API call will be used.

For a GET request, one example would be pulling back a certain collection of books based on some input that the user sent over HTTP. Basically, a search and retrieval based on some criteria. GET requests are usually sent through a query string in the URL and return some simple data from the back-end in jSON or XML format.

For a POST, one example is the user submits a form to be processed. In our library example, perhaps they create a new book. This data is encapsulated into JSON or XML (or another simple data string) using Javascript, and sent over an HTTP POST call to the REST API running on the back-end server. The server takes this data and usually saves it or otherwise works with it.

A PUT call is similar to a POST, but is used to access something which already exists on the server. This would be the user updating and saving an existing boom.

For a delete command, this is obvious. The client-side os requesting one of the things on the back-end to be deleted. The REST API takes this call in and deletes that resource.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly