Rest Best Practices - PowerPoint PPT Presentation

About This Presentation
Title:

Rest Best Practices

Description:

REST, or REpresentational State Transfer, is an architectural style for providing standards between computer systems on the web, making it easier for systems to communicate with each other. Comprised of the best practices for creating REST endpoints. – PowerPoint PPT presentation

Number of Views:54
Slides: 12
Provided by: only2dhir
Category:

less

Transcript and Presenter's Notes

Title: Rest Best Practices


1
REST
  • REST, or REpresentational State Transfer, is an
    architectural style for providing standards
    between computer systems on the web, making it
    easier for systems to communicate with each
    other.
  • We use REST primarily as a way to communicate
    between computer systems on the World Wide Web
    with JSON.

2
REST vs HTTP
  • REST is an architectural style and not the
    standard.
  • HTTP is a protocol to transfer hyper-text.
  • Provides a lot of freedom to implement various
    design best practices.
  • Flexibility to use some other application
    protocol with REST
  • GET, POST, PUT, DELETE
  • GET is meant to perform read a resource.
  • POST is used to create a new resource.
  • PUT is used to update an existing resource.
  • DELETE is for deleting an existing resource.

3
HATEOAS
  • Hypermedia As The Engine Of Application State
  • Provide specific response for a request and
    hypermedia links to related endpoints and thus
    decouple the design

4
HATEOS Sample
5
RESTful API
  • Works on client-server architecture
  • Does not maintain states between two consecutive
    request.
  • Provides flexibility, scalability over
    distributed system
  • Concrete is better than Abstract
  • Here is an example of creating REST endpoints
    with Spring - https//www.devglan.com/spring-boot/
    spring-boot-angular-example

6
URI Formatting
  • Resources are Nouns, Not Verbs
  • HTTP methods are verbs
  • Singular vs Plural
  • /getAllUsers
  • /updateUser/userId
  • /updateUserArticle/articleId

7
Error Handling
  • Maintain uniformity
  • Should include message, status_code, type
  • An Example - https//www.devglan.com/spring-securi
    ty/exception-handling-in-spring-security

8
Status Codes
  • 1XX Informational
  • Communicates transfer protocol-level
    information.
  • 2XX Success
  • Indicates that the clients request was accepted
    successfully.
  • 3XX Redirection
  • Indicates that the client must take some
    additional action in order to complete their
    request.
  • 4XX - Client Error
  • 5XX Server Error

9
Security
  • Some useful resource to secure REST endpoints.
  • https//www.devglan.com/spring-security/spring-web
    flux-rest-authentication

10
Versioning
  • https//api.example.com/v1/authors/2/blogposts/13

11
Documentation
  • Swagger
Write a Comment
User Comments (0)
About PowerShow.com