-
Endpoints example:
/users
(creates user, HTTP POST request) -> POST returns ID of new user
/users/:id
(DELETE / GET requests) -> GET returns JSON user
Choose response status by yourself (e.g. StatusCreated, StatusOK, StatusDeleted etc.)
- Store data in memory ✔️
- Concurrently safe (sync package)
- JSON format on endpoints (json package) ✔️
- Use echo framework (or any other of your choice) ✔️
- Test endpoints with POSTMAN ✔️
Resources:
https://echo.labstack.com/guide
- Centralised logging of incoming request / outgoing response ✔️
- Require basic auth for all requests (use authorisation header). ✔️
- Write unit tests for storage
- Write unit tests for CRUD endpoints ✔️
- Install and run golangci-lint (linter)
OPTIONAL:
- DO NOT USE ready middleware solution, write it yourself
- Add option to log also to file
Resources:
https://echo.labstack.com/middleware
https://echo.labstack.com/guide/testing
- Parameters: port, basic auth user acc/pass, logging enable/disable
- Configuring the application (yaml, env) (use yaml parsing package, environment variables parsing implement yourself or use any available package)
- Validate the configuration (require port, user and pass; make sure port is free; make sure pass is not from the list of forbidden passwords) (use validator v9 or implement simple checks yourself)
OPTIONAL:
- Dockerising application (writing Dockerfile). Separate steps for build and run
Resources:
https://dev.to/ilyakaznacheev/a-clean-way-to-pass-configs-in-a-go-application-1g64
https://pkg.go.dev/github.com/go-playground/validator
https://docs.docker.com/engine/reference/builder/
- Run your docker image from docker-compose file
- Add any docker database image to docker-compose
- Write Go code to connect to this storage from app
- Implement Storage interface using this database connection
Resources:
https://firehydrant.io/blog/develop-a-go-app-with-docker-compose/
https://docs.docker.com/compose/compose-file/compose-file-v3/