Check api.yaml for the API documentation or upload it to https://editor.swagger.io/
- Implementation of Clean Architecture in Go
- Dependency injection
- Context awareness
- Structure of the Project follows the Project Layout.
- API first
- Keep things simple
- Codegen tools and frameworks to speed up the development (I had not much of a free time)
api/*
- Openapi documentation and codegen tools and generated codecmd/*
- main applicationinternal/*
- business-logic
- Echo HTTP framework
- Viper for configuration
- Cobra CLI
- JWT library
- Abstract JSON to analyse dynamic JSON structures
- Mockery
go test ./...
- Check prerequisites
- Add changes to api.yaml
- run
go generate
- Install mockery
- Install oapi-codegen
go build -o app ./cmd
./app
- OR
go run cmd/main.go
docker build -t maksym-code-assignment .
docker run -p8280:8280 maksym-code-assignment
Service should be listening [::]:8280
Get Auth token
curl --location 'http://localhost:8280/auth' \
--header 'Content-Type: application/json' \
--data '{
"username": "maksym",
"password": "trofimenko"
}'
The result:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtYWtzeW0iLCJleHAiOjE2ODA1MTQ3NDB9.GS6bPVYHqDP8XgrqAVl8_yFD1frBcLLOnQA5x2Tu3uY
- Use https://jwt.io/ to check if JWT has a subject
maksym
- Check that expiration time is in one hour
- Copy the token for a next request
Get checksum of a sum of all numbers of a
curl --location 'http://localhost:8280/sum' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtYWtzeW0iLCJleHAiOjE2ODA1MTQ3NDB9.GS6bPVYHqDP8XgrqAVl8_yFD1frBcLLOnQA5x2Tu3uY' \
--header 'Content-Type: application/json' \
--data '{"a":{"b":4},"c":-2, "d": {"a":{"b":4},"c":-2}}'
Result:
4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a
- Go to website https://codebeautify.org/sha256-hash-generator
- Enter number
4
as an input - Check if hash sum matches.
That's it.