Web Programming

Todo REST Service (Interface)

The objective of this exercise is to implement a REST interface of a todo service.

Tasks

  1. Clone the GitLab repository Todo REST Service.
  2. Implement the servlet TodoServlet that uses the todo service to support the following REST requests (see also OpenAPI Definition):
    • GET /api/todos returns all todos
    • GET /api/todos?category={category} returns the todos of the specified category
    • GET /api/todos/{id} returns the todo with the specified identifier
    • POST /api/todos adds a todo
    • 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.
  3. Use the factory ObjectMapperFactory to create a Jackson ObjectMapper and use it to convert Java objects to JSON and vice versa.
  4. (Optional) Verify that the media type headers Content-Type and Accept are set correctly and return an appropriate error response if not.
  5. (Optional) Implement the servlet CategoryServlet which returns the possible todo categories for the REST request GET /api/categories .
  6. Use the Postman application to test the REST service.


Solution