Made using go, gorm and gorilla-mux. Uses mysql as the database. Mysql version is 8.0.26 for macos11.3 on x86_64 (Homebrew). Go version used is go1.17 darwin/amd64.
- Run
go mod download
to download all the required packages. conf.yaml
file has all the configurations required to connect to database, port on which server should run as well as token for request verification.dbName
in conf.yaml is the schema name in which table for this server should be created. Table creation is done using migration. Please make a schema in your mysql and set its name indbName
- Other configurations related to database should also be provided in conf.yaml as they might differ from what I used.
- If
AuthToken
is changed inside the conf.yaml, then please also change thebearerToken
global variable in the postman collection. - Similarly if
port
is changed in conf.yaml, please change thebaseUrl
global variable in the postman collection accordingly.
- After successfully configuration, run
go build -o goTodoList
inside this project folder. This creates the executable namedgoTodoList
inside this folder. - Run
./goTodoList
for starting the server at port configured in conf.yaml.
- After successfully configuration, verfication can be done using postman.
- Import the collection in postman.
- If changes were made in conf.yaml, please make sure to take care of steps 5 and 6 in Steps to Configure.
- Various request and response examples will help you to verify the submission.
- There is a request titled
Missing Authorzation
, its examples shows the response if Auth header is not given as well as if wrong token is given. You can change Api url if you want to check other requests too. - Database constraints and api requests structure (along with parameters) are explained in necessary comments. Please read those comments to understand and run requests in postman accordingly. Only
POST
,PUT
and filter requests need some explaination, so only those are explained in detail POST
andPUT
requests will be checked to follow constraints specified in the modelTodoItem
. If they follow the constraints request will be successful else an error will be returned. The request response for requests that don't follow constraints is similar inPOST
andPUT
are same so I have not added all failed request forPUT
. I have added failed requests for many cases with their responses.