RESTful Web Services
Juan Sandoval
@juanitodread
Agenda
Introduction to REST
Introduction
Principles
Design RESTful services
● Introduction to REST
REST is a set of architectural principles that
answer the following questions:
Why is the web so prevalent and ubiquitous?
What makes the web scale?
How can I apply the architecture of the Web
to my own applications?
● Principles
REST: REpresentational State Transfer
Addressable resources
A uniform, constrained interface
Representation-oriented
Communicate statelessly
Hypermedia As The Engine Of Application State
(HATEOAS)
Addressability
Is the idea that every object and resource in your system
is reachable through a unique identifier.
In REST is managed through the use of URIs.
Each HTTP request must contain the URI of the object you
are requesting information
scheme://host:port/path?query#fragment
Constrained Interface
You must use the finite set of operations of HTTP. Each
method has a specific purpose and meaning.
Get
Put
Delete
Post
Head
Options
Representation-Oriented
The representation is the message body of
your request or response. An HTTP message
body may be in any format the server and
client want to exchange.
HTTP content negotiation is a very powerful
tool when writing web services.
Communicate Statelessly
Is the idea that there is no client session data
stored on the server. The server only records
and manages state of the resource it exposes.
If there needs to be session-specific data, it
should be held and maintained by the client
and transferred to the server with each
request as needed.
HATEOAS
The idea is use Hypermedia As The Engine Of Application
State. Hypermedia is a document-centric approach with
the added support for embedding links to other services
and information within that document format.
HATEOAS enforces with each request returned from a
server it tells you what new interactions you can do next,
as well as where to go to transition the state of your
applications.
Design RESTful Services
Define the object model.
Define a distributed interface through HTTP.
Define a set of URIs that represent the entry points into
our system.
Define the data format that we will use to exchange
information between services and clients.
Define which HTTP methods are allowed by each exposed
URI and what those methods do.
Code of the course: e-commerce-rest-api
Thank you!

RESTfulll web services

  • 1.
    RESTful Web Services JuanSandoval @juanitodread
  • 2.
  • 3.
    ● Introduction toREST REST is a set of architectural principles that answer the following questions: Why is the web so prevalent and ubiquitous? What makes the web scale? How can I apply the architecture of the Web to my own applications?
  • 4.
    ● Principles REST: REpresentationalState Transfer Addressable resources A uniform, constrained interface Representation-oriented Communicate statelessly Hypermedia As The Engine Of Application State (HATEOAS)
  • 5.
    Addressability Is the ideathat every object and resource in your system is reachable through a unique identifier. In REST is managed through the use of URIs. Each HTTP request must contain the URI of the object you are requesting information scheme://host:port/path?query#fragment
  • 6.
    Constrained Interface You mustuse the finite set of operations of HTTP. Each method has a specific purpose and meaning. Get Put Delete Post Head Options
  • 7.
    Representation-Oriented The representation isthe message body of your request or response. An HTTP message body may be in any format the server and client want to exchange. HTTP content negotiation is a very powerful tool when writing web services.
  • 8.
    Communicate Statelessly Is theidea that there is no client session data stored on the server. The server only records and manages state of the resource it exposes. If there needs to be session-specific data, it should be held and maintained by the client and transferred to the server with each request as needed.
  • 9.
    HATEOAS The idea isuse Hypermedia As The Engine Of Application State. Hypermedia is a document-centric approach with the added support for embedding links to other services and information within that document format. HATEOAS enforces with each request returned from a server it tells you what new interactions you can do next, as well as where to go to transition the state of your applications.
  • 10.
    Design RESTful Services Definethe object model. Define a distributed interface through HTTP. Define a set of URIs that represent the entry points into our system. Define the data format that we will use to exchange information between services and clients. Define which HTTP methods are allowed by each exposed URI and what those methods do.
  • 11.
    Code of thecourse: e-commerce-rest-api Thank you!

Editor's Notes

  • #6 Here is an example of query string within a URI: http://example.com/customers?zipcode=45601
  • #7 Get: Is a read-only operation. It is used to query the server for specific information. Is idempotent and safe operation. Idempotent means that no matter how many times you apply the operation, the result is always the same. Put: Request that the server store the message body sent with the request under the location provided in the HTTPmessage. It is usually modeled as an insert or update. It is also idempotent. Delete: Is used to remove resources. It is idempotent as well. Post: Is the only nonidempotent and unsafe operation. Each POST method is allowed to modify the service in a unique way. Head: Is exactly like GET except that instead of returning a response body, it returns only a response code and any headers associated with the request. Options: Is used to request information about the communication options of the resource you are interested in.