Lecture 9 - REST Flashcards
What does a URI tell us? (REST addressable resources basic principle)
protocol
host/port
resource path
ex: scheme://host:port/path?queryString#fragment
URI parameters
Query parameters
and matrix parameters?
/customers/{customer-id}
http://sales.com/customers?zip=02115
color=black
(name-value pairs after segment)
A uniform constrained interface (UCI) is a standardized way of interacting with a system. What are the operations? Are they idempotent? (REST basic principle)
GET
PUT
DELETE
POST
All idempotent EXCEPT for post (can submit a form multiple times).
What does REST stand for?
REpresentational State Transfer
What does REST provide?
Service-oriented interface
Reduces load on server (HTTP caching)
Scalable (Stateless + caching)
Uses same principles as internet (Uniform interface)
Can support any data format, any programming language.
What is GraphQL?
Developed by Facebook, query language, less requests required.
what is gRPC?
Developed by Google, alternative non OOP method (C), low overhead, protocol buffers.
What are websockets?
Full-duplex binary protocol (think of c project)
Establish TCP connection, good for real-time low latency.
What is MQTT (Message Queuing Telemetry Transport)?
Lightweight protocol for IoT devices (wearables, smart home devices, etc).
Why is REST representation-oriented?
(Basic principle)
Each service is addressable through a URI.
Representations are exchanged between client and service.
Ex: JSON, XML, YAML
With HTTP the representation is in the body of the request or response
What does it mean that REST communicates statelessly?
RESTful applications do not maintain sessions/conversations.
Each request is independent and contains all information needed to process the request.
(scalability, less work from server)
Resources can have their own state, client responsible for holding conversational state
(RESTful services do not rely on sessions or cookies)
What is HATEOAS (Hypermedia as the Engine of Application State)?
Document can have links (embedded in the response) to other services or documents.
Ex: next, previous
GET
POST
PUT
DELETE
when to use?
GET - Get a list of values using query parameters or getting an individual item with an id encoded in URI
POST - sends a representation of the object to the URI (no id)
PUT - sends a representation of the object to the URI (id known)
DELETE - objects URI and delete (200 ok or 204 no content)
Put vs Post:
put for update or create (id-known, idempotent)
post for create or submit data (id-unknown, non-idempotent)