TODO Service provides a framework for building a microservice in go-lang.
There are two ways you can develope
Using devcontainers is the recommended approach as it ensures your development machine stays clean as well as provides consistency between different developers reducing the "works on my machine" problem.
To develope in a dev container follow these steps:
- Install Docker and VSCode
- Install the Dev Containers VSCode extension
- Open the code base in vscode
- You will be prompted to reopen the project in a dev container, follow the instructions
Install the go language and your favorite IDE, then start developing using whichever method works best for you.
if you use Visual studio code, consider installing Rich Go language support for Visual Studio Code by the go team at Google. It provides several nifty features.
go generate
go build
./todo-service --config ./config/development.yaml server
curl -X POST "http://localhost:8080/todos" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"summary": "New Todo item",
"done": false
}'
curl http://localhost:8080/todos
You can get the ID of the TODO item from either the response to the Create TODO API call, or the response to the List TODO API call
curl http://localhost:8080/todos/${TODO_ID}
This method replaces all values of the TODO item with the specified ID with the ones provided in the request body.
You can get the ID of the TODO item from either the response to the Create TODO API call, or the response to the List TODO API call
curl -X PUT http://localhost:8080/${TODO_ID} \
-H 'Content-Type: application/json' \
-d '{"summary": "replaced", "done": true}'
This method folows the JSONPatch format to update specific values of the todo with the specified ID with the ones provided in the request body.
You can get the ID of the TODO item from either the response to the Create TODO API call, or the response to the List TODO API call
curl -X PATCH http://localhost:8080/todos/${TODO_ID} \
-H 'accept: application/json' \
-H 'Content-Type: application/json-patch+json' \
-d '[
{
"op": "replace",
"path": "/summary",
"value": "patched"
},
{
"op": "replace",
"path": "/done",
"value": true
}
]'
You can get the ID of the TODO item from either the response to the Create TODO API call, or the response to the List TODO API call
curl -X DELETE http://localhost:8080/todos/${TODO_ID}