#Book REST service.
mvn clean package
Use:
http://localhost:8080/books/readers/{reader_id}/books/{book_id}
Methods:
- GET - book_id not use, list of book for reader
Url `http://localhost:8080/books/readers/1/books` - PUT - add book to reader
Url `http://localhost:8080/books/readers/1/books/2` - DELETE - 'back' book from reader
Url `http://localhost:8080/books/readers/1/books/2`
Bonus:
Add book:
Method: PUT
Url: http://localhost:8080/books/books/
Body: {"book":{"title":"title 1", "author":"Author 100"}}
Tasks list:
- MyBatis query for get Reader`s by Book, get Book`s by Reader.
- Create 3 Book, 2 Reader, 1 Reader read 0 Book, 1 Reader read 2 Book. Test 1 query.
- Run tomcat.
- Create servlet.
- War.
In pom file:
<!--<packaging>jar</packaging>-->
<packaging>war</packaging>
- Test injection mappers into Servlet throught Services.
- Parse url.
- Dispatch url`s
- Controllers. Link url with Controllers throught reflection. Controller interface.
- Select JSON lib.
- Http methods parse.
- End interface, Controllers.
- Decorate myBatis mappers, entities.
- Entity to JSON decore.
- REST pribciples.
- URL:
Example: /books/v1.0/books/10
../books/search/Title
Add parsing !!! - Params:
URL - only query, JSON - all data. - Methods:
- GET - list, concrete
/books/v1.0/books/10
/books/v1.0/books
Search: ?title=book1 - DELETE - удаление
/books/v1.0/books/10 - PUT - idempotent - add, update
??? - POST - ???
- GET - list, concrete
- Errors:
- 200 OK
- 201 Created (Запись создана)
- 400 Bad Request (некорректный запрос)
- 404 Not Found (Данные не найдены)
- 500 Internal server error (внутренняя ошибка сервера)
return text
error JSON format
- Methods:
- выдать книгу абоненту; readers/{id}/books/{id} put
- принять книгу у абонента; readers/{id}/books/{id} delete?
- получить список книг, выданных заданному абоненту readers/{id}/books get
TODO:
-
Test REST.
-
End all domain REST.
-
Rest:
- Version:
v1.0 - Validation?