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 downloadto download all the required packages. conf.yamlfile has all the configurations required to connect to database, port on which server should run as well as token for request verification.dbNamein 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
AuthTokenis changed inside the conf.yaml, then please also change thebearerTokenglobal variable in the postman collection. - Similarly if
portis changed in conf.yaml, please change thebaseUrlglobal variable in the postman collection accordingly.
- After successfully configuration, run
go build -o goTodoListinside this project folder. This creates the executable namedgoTodoListinside this folder. - Run
./goTodoListfor 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,PUTand filter requests need some explaination, so only those are explained in detail POSTandPUTrequests 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 inPOSTandPUTare same so I have not added all failed request forPUT. I have added failed requests for many cases with their responses.