This is a simple JSON web service that allows you to create, read, update, and delete todos.
You need a JSON client to interact with the web service. cURL examples are provided below.
- Java 17
Clone the repository from https://github.com/clemens-tolboom/TodoWebservice
Run the following command :
./gradlew build
./gradlew run
The h2 database is located in ./database/todo.db.mv.db
Visit http://localhost:8080/ in your browser. There you will see a list of all the todos.
You can use the following endpoints to interact with the Todo web service using your own client:
- GET /todos: Get all todos
- GET /todos/:id: Get a todo by ID
- POST /todos: Create a new todo
- PUT /todos/:id: Update a todo
- DELETE /todos/:id: Delete a todo
You can also use cURL to interact with the web service.
curl -X GET http://localhost:8080/todos
ID=17
curl -X GET http://localhost:8080/todos/$ID
curl -X POST -H "Content-Type: application/json" -d '{"title": "My todo", "completed":false}' http://localhost:8080/todos
ID=12
curl -X PUT -H "Content-Type: application/json" -d '{"title": "My todotodo", "completed": true}' http://localhost:8080/todos/$ID
ID=123
curl -X DELETE http://localhost:8080/todos/$ID
- The database "The file is locked:" when running two instances of the application at the same time.
- The used database H2 has a CVE-2022-45868
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
is covered by adding hard dependency on slf4j-simple:1.7.25
.