A Web service Todo List (API) project designed by Go Language and using MongoDB as a database for storing and managing tasks.
- ENV: https://github.com/joho/godotenv
- MUX: https://github.com/gorilla/mux
- Mongo: https://go.mongodb.org/mongo-driver
-
Get a single task
- Route:
host:8000/api/v1/get/{_id}/
- Description: replace {_id} with mongodb document id
- Method: GET
- Route:
-
Get all tasks
- Route:
host:8000/api/v1/get/
- Description: return a list of tasks
- Method: GET
- Route:
-
Insert a new task
- Route:
host:8000/api/v1/craete/
- Description: send a JSON request with these fields:
{ "name": "name of task", "description": "info about task", "status": true }
- method: POST
- Route:
-
Delete a task
- Route:
host:8000/api/v1/delete/{_id}/
- Description: replace {_id} with desired task id returned in create response
- Method: DELETE
- Route:
-
Update/Edit a task
- Route:
host:8000/api/v1/update/{_id}
- Description: replace {_id} with desired task id and send a JSON in body same as create route.
- Method: PUT
- Route:
You can run this app using 2 methods:
-
Manual
- Clone this repo, rename
env.env
to.env
, fill fields in.env
file as desired - Run
go build .
- Run binary named
./go-api-todolist
- Clone this repo, rename
-
Docker compose
- Clone this repo.
- Run
docker-compose up -d
and wait for app to run onlocalhost:8000
- Amir
- Max Base
© Copyright 2022, Max Base