Web Programming
Todo REST Service (Interface)
The objective of this exercise is to implement a REST interface of a todo service.
Tasks
-
Clone the GitLab repository Todo REST Service.
-
Implement the servlet
TodosServlet that uses the todo service to support the following REST requests regarding all todos
(see also OpenAPI Definition):
GET /api/todos returns all todos
GET /api/todos?category={category} returns the todos of the specified category
POST /api/todos adds a todo
Make sure to return appropriate status codes, especially in case of error.
-
Implement the servlet
TodoServlet that uses the todo service to support the following REST requests regarding a single todo
(see also OpenAPI Definition):
GET /api/todos/{id} returns the todo with the specified identifier
PUT /api/todos/{id} updates the todo with the specified identifier
DELETE /api/todos/{id} deletes the todo with the specified identifier
Make sure to return appropriate status codes, especially in case of error.
-
Use the factory
ObjectMapperFactory to create a Jackson ObjectMapper and use it to convert Java objects to JSON and vice versa.
-
(Optional) Verify that the media type headers
Content-Type and Accept are set correctly and return an appropriate error response if not.
-
(Optional) Implement the servlet
CategoriesServlet which returns the possible todo categories for the REST request GET /api/categories .
-
Use the Postman application to test the REST service.
Solution