3. REST & LUMEN
1. Web Service & Web API
2. RESTful APIs
3. Insomnia REST
4. Lumen Micro Framework
5. Demo
4. 1.Web Service & Web API
• Web Service andWeb API are different
• Web Service covers:
– XML-RPC (XML)
– SOAP &WSDL(XML)
– GraphQL (JSON)
– REST (JSON)
5. 2. RESTful APIs
a. HTTPVerb
b. RESTful URL
c. Code response
d. JSON Format
6. 2.a. HTTPVerb
- Method GET (get resources)
- Method POST (create new resource)
- Method PUT (update/replace entire resource)
- Method PATCH (update part of resource)
- Method DELETE (delete resource)
7. 2.b. RESTful URL
- Method GET (get resources)
- https://domain.com/lessons
- https://domain.com/lessons?category=1&category=2
- https://domain.com/lessons?search=rasanrasan
- https://domain.com/lessons/1
- Method POST (create new resource)
- https://domain.com/lessons
- Method PUT (update/replace entire resource)
- https://domain.com/lessons/2
- Method PATCH (update part of resource)
- https://domain.com/lessons/3
- Method DELETE (delete resource)
- https://domain.com/lessons/4
8. 2.c. Code Response
- Method GET (get resources)
- 200: resource found
- Method POST (create new resource)
- 201: resource created
- Method PUT (update/replace entire resource)
- 200: resource updated
- Method PATCH (update part of resource)
- 200: resource updated
- Method DELETE (delete resource)
- 200: resource deleted
- General error code
- 404: resource not found
- 422: unprocessable entity
- 500: internal server error