2. What is REST ?
• Representational state transfer
• Defined by Roy Fielding in his 2000 PhD dissertation
"Architectural Styles and the Design of Network-
based Software Architectures" at UC Irvine.
• Is not a standard.
• Is not a protocol.
4. REST Architectural Elements -- Data Elements
Data Element Modern Web Examples
resource
the intended conceptual target of a
hypertext reference
resource identifier URL, URN
representation HTML document, JPEG image
representation metadata media type, last-modified time
resource metadata source link, alternates, vary
control data if-modified-since, cache-control
5. RESTful Web Service
• Addressability
– Resources are identified by URIs
• Statelessness
– No connection state maintained between REST invocations
• Connectedness
– Resources should link together in their representations
• Uniform interface
– HTTP GET, PUT, POST, DELETE, HEAD, OPTIONS
– HTTP method header
– HTTP status codes
6. Relationship between URL and HTTP methods
Collection
http://api.example.com/resources/
• GET : List of collection's members
• PUT : Replace the entire collection with another
collection.
• POST : Create a new entry in the collection.
• DELETE : Delete the entire collection.
7. Relationship between URL and HTTP methods
Element
http://api.example.com/resources/17
• GET : Retrieve a representation of the addressed
member of the collection.
• PUT : Replace the addressed member of the collection,
or if it does not exist, create it.
• POST : Not generally used. Treat the addressed member
as a collection in its own right and create a new entry
within it.
• DELETE : Delete the addressed member of the collection.
8. RESTful API in Java World
• JAX-RS
• Implementations
– Apache CXF
– Jersey
– RESTeasy
– Restlet
– SpringBoot
9. Specification Formats for REST APIs
• RAML 、 Swagger 、BluePrint
• Why Swagger?
– Open API Initiative (OAI) - Has announced an
open governance model around the Swagger
Specification under the Linux Foundation.
– Various languages supported.
12. Reference
• Wiki
• Swagger.io
• https://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-
introduction-to-rest.html
• Roy Fielding in his 2000 PhD dissertation "Architectural Styles and the
Design of Network-based Software Architectures" at UC Irvine.