A TODO list REST API build with Golang.
Stacks:
- Golang 1.14
- Postgres 12 (self signed cert with Docker)
pkgs/tools:
- go-chi/chi
- jinzhu/gorm
- golang-migrate/migrate
- golangci/golangci-lint
GET /tasks
List all tasks
Example:
curl --header "Content-Type: application/json" \
--request GET \
http://localhost:8080/tasks/
POST /tasks
Create new task
Example:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"project name","description":"project description"}' \
http://localhost:8080/tasks/
PATCH /tasks/{id}
Update a task
Example:
curl --header "Content-Type: application/json" \
--request PATCH \
--data '{"name":"first project","description":"first project description"}' \
http://localhost:8080/tasks/{uuid}
GET /tasks/{id}
Get a task
Example:
curl --header "Content-Type: application/json" \
--request GET \
http://localhost:8080/tasks/{uuid}
DELETE /tasks/{id}
Delete a task
Example:
curl --header "Content-Type: application/json" \
--request DELETE \
http://localhost:8080/tasks/{uuid}
With Docker
- Make sure you have
Docker
andDocker Compose
installed. - Clone the Repository.
- Run
make up
from app root directory. It may take few more minutes forinstall packages
and start the container. - Run
make run
from app root directory to run the API. - Open
http://127.0.0.1:8080
(default config) in your web browser.
With Docker
- Make sure you have installed all the packages (including tests), or you could run
make install
for this. - Run
make ci-test
from app root directory. it will run all tests for you.
- This project is using Multi-stage to build the final image, Run
make build
from app root directory.
notice: in order to run the api in the final image, need to provide db connection config through env,
please check /cmd/todo/api.go
Feedback is welcome.