$30 off During Our Annual Pro Sale. View Details »

REST Course - First Class

REST Course - First Class

Avatar for Victor Costa Romano

Victor Costa Romano

July 22, 2019
Tweet

More Decks by Victor Costa Romano

Other Decks in Programming

Transcript

  1. Motivation Incorrect usage of REST pattern Incorrect usage of HTTP

    endpoints Lack of understanding to create or adapt HTTP endpoints to a RESTful API Level the knowledge about REST across the team
  2. Syllabus • First class ◦ Basic concepts ◦ Basic CRUD

    API ◦ Richardson Maturity Model • Second class ◦ Complete CRUD API ◦ Richardson Maturity Model ◦ Easy creation of a REST API ◦ Tools • Third class ◦ Deploy ◦ Tests ◦ Documentation
  3. REpresentational State Transfer Introduced by Roy Fielding in his dissertation

    in 2000 Architectural style for distributed hypermedia systems Defines a set of constraints to be used for creating web services
  4. REST Constraints 1. Client-server 2. Stateless 3. Cacheable 4. Uniform

    interface 5. Layered system 6. Code on demand (optional)
  5. 1. Client-server Servers and clients may also be replaced and

    developed independently, as long as the interface between them is not altered.
  6. 2. Stateless No client context shall be stored on the

    server between requests. The client is responsible for managing the state of the application.
  7. 3. Cacheable Well-managed caching partially or completely eliminates some client-server

    interactions, further improving scalability and performance.
  8. 4. Uniform Interface Once a developer becomes familiar with one

    of your API, he should be able to follow the similar approach for other APIs.
  9. 5. Layered System Clients cannot ordinarily tell whether they're connected

    directly to the end server, or to an intermediary along the way.
  10. 6. Code on Demand (Optional) All above constraints help you

    build a truly RESTful API and you should follow them. Still, at times you may find yourself violating one or two constraints. Do not worry, you are still making a RESTful API – but not “truly RESTful”.
  11. REST != HTTP REST don't enforce the usage of any

    specific protocol Clients and servers exchange representations of resources by using a standardized interface and protocol
  12. Richardson Maturity Model Level 0 - Remote Procedure Invocation Level

    1 - Resources Level 2 - HTTP Verbs and Codes Level 3 - Hypermedia Controls
  13. Spring De facto standard framework to build Java enterprise applications

    Core functionalities: • Dependency injection • Events • Resources • Internationalization (i18n) • Aspect-oriented programming (AOP)
  14. Spring Boot Facilitates the creation and setup of Spring applications

    Provides default configuration for Spring framework and several other libraries
  15. HTTP Codes • 1xx - Informational • 2xx - Successful

    • 3xx - Redirection • 4xx - Client Error • 5xx - Server Error