REST/JSON API with echo
Using a framework to make api development and test easier
Requirements
- go 1.22
- echo v4 (api)
- goqu v9 (db/query builder)
- docker 25 (to provision a postgres)
How to run
Be sure to have docker compose running the development postgres database:
bash
# cd exercises/0016-rest-json
docker compose -f infrastructure/docker-compose.yml up -dThen build and run like any normal go application:
bash
go build
./0016-rest-jsonHow to test
Perform some requests to the running API:
bash
# 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