Rest API

REST

Definition: https://en.wikipedia.org/wiki/Representational_state_transfer

Note:

  • An remote invocation method
  • Key
  1. Resource: URI/URL
  2. HTTP method: POST, PUT, DELETE, PUT etc
  3. HTTP status: 200. 201, 204, 400, 404, 409, 500 etc
  • Versus SOAP
  1. Resource VS Action
  2. JSON VS SOAP
  • Design API
  1. PATH PARAM
  2. QUERY PARAM

SPRING REST USAGE

Example: https://github.com/GrapeBaBa/rest-demo

./mvnw eclipse:eclipse or ./mvnw idea:idea
./mvnw spring-boot:run

Note:

  • Error response
  • HTTP status code
  • JSON serialization

Thinking problems

  • Pagination query API design
  • File upload API design
  • Multiple items deletion API design