From cb292b828b307c8e70f05ce70b9a0ec77b6774e9 Mon Sep 17 00:00:00 2001 From: georgeas <george.a.stoica@ntnu.no> Date: Thu, 15 Oct 2020 13:29:14 +0200 Subject: [PATCH] add slides lecture 17 --- lectures/revealjs/17-rest-api.adoc | 97 ++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 lectures/revealjs/17-rest-api.adoc diff --git a/lectures/revealjs/17-rest-api.adoc b/lectures/revealjs/17-rest-api.adoc new file mode 100644 index 0000000..3a20c4b --- /dev/null +++ b/lectures/revealjs/17-rest-api.adoc @@ -0,0 +1,97 @@ += REST APIs +:customcss: slides.css +:icons: font +:includedir: revealjs/includes/ +:LECTURE_TOPIC: REST APIs +:LECTURE_NO: 17th Lecture + +include::{includedir}header.adoc[] + +[.smaller-80][.center-paragraph] +IT1901 Fall 2020 - {LECTURE_NO} + +[.smaller-80] +== Overview + +- REST APIs +** HTTP requests +** Methods +** APIs +** REST Recap + + + +== HTTP requests + - **H**yper**t**ext **T**ransfer **P**rotocol (HTTP) + - clients (e.g. browser) send requests + - servers (web site / service) send responses + +== HTTP Request message + + - a request line `GET / HTTP/1.1` + - request headers - `User-Agent`, `Accept`, `Content-Type` etc. + - an empty line (containing only a `carriage return` and a `line feed`) + - an optional message body + +== HTTP Methods + +- HTTP specification defines `methods` to indicate what action is expected from the server +** GET, HEAD, OPTIONS +** POST, PUT, PATCH +** DELETE + +== APIs + +- **A**pplication **P**rogramming **I**nterface +- "Glue" that makes possible different pieces of software to interoperate +- It is meant to be machine readable / usable +- APIs are everywhere - at different levels - software libraries, operating system, applications, web services etc. + +== APIs (2) + +- typically a set of calls or requests, expected call format, expected response format, data structures +- separate the implementation from the interface +- allow programs in one language to use functionality written in some other language +- cater to modular software + +[background-color = "#124990"] +[color = "#fff6d5"] +== REST + +[.smaller-80] +== REST +- **RE**presentational **S**tate **T**ransfer (REST) +- architectural style involving use of Web Services +- set of constraints are applied +** client server +** statelessness (no client context is stored on the server side) +** cacheability (responses state if they can be cached or not) +** uniform interface +** layered system (adding layers like proxy or load balancer) + + +== REST (cont.) + +- Web services that implement REST are called RESTful APIs +- a base URI, example: https://gitlab.stud.idi.ntnu.no/api/v4 +- set of exposed web resources +- standard HTTP methods (e.g., GET, POST, PUT, PATCH and DELETE); +- data formats for requests and responses (json, xml, etc) + +== ! + +image::../images/lecture12/rtodo.png[canvas, size=contain] + +== Security considerations + +- CORS (Cross-Origin Resource Sharing) +** headers `Access-Control-Allow-Origin` +- Authentication (Basic Auth, OAuth etc) +- HTTPS (HTTP over TLS) + + +[background-color = "#124990"] +[color = "#fff6d5"] +== Summary + +include::{includedir}footer.adoc[] \ No newline at end of file -- GitLab