1. The type Book controller.
1.1. Create book.
Type: POST
Author: Baeldung.
Content-Type: application/json
Description: Create book.
Body-parameters:
| Parameter | Type | Description | Required | Since | Example |
|---|---|---|---|---|---|
id | int64 | Book ID | false | - | 0 |
author | string | Author | false | - | |
title | string | Book Title | false | - | |
price | double | Book Price | false | - | 0.0 |
Request-example:
curl -X POST -H "Content-Type: application/json" -i 'localhost:8080/api/v1/books' --data '{
+ "id": 0,
+ "author": "",
+ "title": "",
+ "price": 0.0
+}' Response-fields:
| Field | Type | Description | Since | Example |
|---|---|---|---|---|
id | int64 | Book ID | - | 0 |
author | string | Author | - | |
title | string | Book Title | - | |
price | double | Book Price | - | 0.0 |
Response-example:
{
+ "id": 0,
+ "author": "",
+ "title": "",
+ "price": 0.0
+} 1.2. Get all books.
Type: GET
Author: Baeldung.
Content-Type: application/x-www-form-urlencoded
Description: Get all books.
Request-example:
curl -X GET -i 'localhost:8080/api/v1/books' Response-fields:
| Field | Type | Description | Since | Example |
|---|---|---|---|---|
id | int64 | Book ID | - | 0 |
author | string | Author | - | |
title | string | Book Title | - | |
price | double | Book Price | - | 0.0 |
Response-example:
[
+ {
+ "id": 0,
+ "author": "",
+ "title": "",
+ "price": 0.0
+ }
+] 1.3. Gets book by id.
Type: GET
Author: Baeldung.
Content-Type: application/x-www-form-urlencoded
Description: Gets book by id.
Path-parameters:
| Parameter | Type | Description | Required | Since | Example |
|---|---|---|---|---|---|
id | int64 | the book id | true | - | 1 |
Request-example:
curl -X GET -i 'localhost:8080/api/v1/book/{id}' Response-fields:
| Field | Type | Description | Since | Example |
|---|---|---|---|---|
id | int64 | Book ID | - | 0 |
author | string | Author | - | |
title | string | Book Title | - | |
price | double | Book Price | - | 0.0 |
Response-example:
{
+ "id": 0,
+ "author": "",
+ "title": "",
+ "price": 0.0
+} 1.4. Update book response entity.
Type: PUT
Author: Baeldung.
Content-Type: application/json
Description: Update book response entity.
Path-parameters:
| Parameter | Type | Description | Required | Since | Example |
|---|---|---|---|---|---|
id | int64 | the book id | true | - | 1 |
Body-parameters:
| Parameter | Type | Description | Required | Since | Example |
|---|---|---|---|---|---|
id | int64 | Book ID | false | - | 0 |
author | string | Author | false | - | |
title | string | Book Title | false | - | |
price | double | Book Price | false | - | 0.0 |
Request-example:
curl -X PUT -H "Content-Type: application/json" -i 'localhost:8080/api/v1/books/{id}' --data '{
+ "id": 0,
+ "author": "",
+ "title": "",
+ "price": 0.0
+}' Response-fields:
| Field | Type | Description | Since | Example |
|---|---|---|---|---|
id | int64 | Book ID | - | 0 |
author | string | Author | - | |
title | string | Book Title | - | |
price | double | Book Price | - | 0.0 |
Response-example:
{
+ "id": 0,
+ "author": "",
+ "title": "",
+ "price": 0.0
+} 1.5. Delete book.
Type: DELETE
Author: Baeldung.
Content-Type: application/x-www-form-urlencoded
Description: Delete book.
Path-parameters:
| Parameter | Type | Description | Required | Since | Example |
|---|---|---|---|---|---|
id | int64 | the book id | true | - | 1 |
Request-example:
curl -X DELETE -i 'localhost:8080/api/v1/book/{id}' Response-example:
true