-
Notifications
You must be signed in to change notification settings - Fork 5
Workshop #3: Enhancing API layer
Workshop #3 is about enhancing the API layer - not only the REST one but the API contract in general (e.g. between modules communicating with each other). Therefore, you can find topics such as:
- HTTP basics (methods, status codes, etc.)
- REST API conventions
- Swagger definitions
- Java components visibility
- SOLID
This workshop
You can find the source code that represents the status of the project after this workshop - TBD
Let's recollect what the HTTP is and what is the proper way to use it in terms of building efficient and readable REST APIs :)
HTTP stands for Hyper Text Transfer Protocol. This protocol is used to transfer data (HTML documents, CSS/JS files, JSON data, etc.) over the Internet between clients and servers via HTTP requests and HTTP responses.
We can distinguish 5 mostly used HTTP methods: GET, POST, PUT, DELETE, PATCH (full list available on https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods site).
| HTTP Method | Description | Safe | Idempotent | Has request body | Has response body |
|---|---|---|---|---|---|
| GET | Read a resource | Yes | Yes | Optional | Yes |
| POST | Create a new resource | No | No | Yes | Yes |
| PUT | Update a resource | No | Yes | Yes | Yes |
| DELETE | Delete a resource | No | Yes | Optional | Optional |
| PATCH | Update partially a resource | No | No | Yes | Yes |
HTTP response status codes indicate the result of the processed HTTP request. They are grouped into five classes:
-
1xx: Informational responses -
2xx: Successful responses -
3xx: Redirection responses -
4xx: Client error responses -
5xx: Server error responses
A full list of HTTP status codes can be found on https://developer.mozilla.org/en-US/docs/Web/HTTP/Status site.