HTTP and REST - andrewkyllo-401-advanced-javascript/seattle-javascript-401d34 GitHub Wiki
HTTP
- (Hyper Text Transfer Protocol) is a stateless request-response application layer protocol
HTTP Requests
- The first line of request contains the METHOD, URL, and HTTP VERSION
- The following lines are the request HEADER
Example HTTP Request:
POST /api/note HTTP/1.1
Host: api.example.com
Origin: www.example.com
Authorization: Bearer bHVsIHRoaXMgaXMgYSBmYWtlIHNlY3JldCB0b2tlbg==
Accept: application/json
Content-Type: application/json; charset=UTF-8
Content-Length: 58
{"title":"kata","content":"get 100 points on hacker rank"}
HTTP Response
- First line of response contains the HTTP VERSION, STATUS CODE, and STATUS MESSAGE.
Example HTTP REsponse:
HTTP/1.1 200 OK
Date: Tue, 22 Aug 2017 06:34:16 GMT
Content-Type: application/json; charset=UTF-8
Content-Encoding: UTF-8
Content-Length: 82
Last-Modified: Mon, 21 Aug 2017 12:10:38 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
ETag: "3f80f-1b6-3e1cb03b"
Connection: close
{"id":"1234123412341324","title":"kata","content":"get 100 points on hacker rank"}
REST
- An acronym for REpresentational State Transfer.
- Endpoints deliver data in JSON format.
REST Documentation (Swagger)
- Presents developers a way to see how to use an API and actually use it.
Generating your own Swagger Documentation
- The swagger documentation service allows you to generate the swagger documentation simply by visiting your API and analyzing the output.