Skip to content

Latest commit

 

History

History

0016-rest-json

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:

# 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

How to test

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

Noteworthy

  • I have a fond for query builders since knex and [goqu][goqu] is a nice surprise.
  • The echo's bind api delivers the best data handling experience in go ecosystem so far.