This project provides an easy example of a CRUD REST service.
The Content-Type of HTTP header should be like this Content-Type: application/json; charset=utf-8
.
{
"id": 1,
"title": "Novel Book",
"category": "novel",
"publicationDate": "2010-01-01"
}
[
{
"id": 1,
"title": "Book 1",
"category": "science",
"publicationDate": "2016-01-01"
},
{
"id": 2,
"title": "Book 2",
"category": "literature",
"publicationDate": "2017-02-01"
}
]
GET /books
Returns all Books by default, query parameters title
, category
,publicationDate
can be used to filter the results.
Filter by query parameters:
?title=effectivejava
?category=computer
?publicationDate=2000-01-01
GET /books/:id
Return the specific Book by id.
POST /books
Request Body:
{
"id": 1,
"title": "Thinking in java",
"category": "java",
"publicationDate": "2006-02-20"
}
Return the new added Book
PUT /books/:id
Request Body:
{
"title": "Thinking in java",
"category": "java",
"publicationDate": "2006-02-20"
}
If the book with the id does not exist, return the created book If the book with the id exists, return the updated book This API can not change id of any existed book
DELETE /books/:id