REST/JSON API with echo
Using a framework to make api development and test easier
- go 1.22
- echo v4 (api)
- goqu v9 (db/query builder)
- docker 25 (to provision a postgres)
Be sure to have docker compose running the development postgres database:
# cd exercises/0016-rest-json
docker compose -f infrastructure/docker-compose.yml up -d
Then build and run like any normal go application:
go build
./0016-rest-json
Perform some requests to the running API:
# list todos
curl -X GET http://localhost:1323/todos
# find by id
curl -X GET http://localhost:1323/todos/2
# insert todo
curl -X POST --json '{"description":"new task"}' http://localhost:1323/todos
# update todo
curl -X PUT --json '{"description":"task updated"}' http://localhost:1323/todos/2
# delete todo
curl -X DELETE http://localhost:1323/todos/3