A simple Golang application HTTP server that listens on port 8989. The server calculate factorial of a number and return the result.
- Clone the repository
git clone https://github.com/Nikolay200669/go-ks.git && \
cd go-ks
- Run the following command to start the server:
go run main.go
curl -X POST http://localhost:8989/calculate \
-H 'Content-Type: application/json' \
-d '{"a": 5, "b": 3}'
- Use integration test:
go test -v ./...
output should be:
=== RUN TestCalcHandler
=== RUN TestCalcHandler/Run_test_OK
=== RUN TestCalcHandler/Run_test_middleware
--- PASS: TestCalcHandler (0.00s)
--- PASS: TestCalcHandler/Run_test_OK (0.00s)
--- PASS: TestCalcHandler/Run_test_middleware (0.00s)
PASS
ok github.com/Nikolay200669/go-ks 0.335s
- Run Docker:
docker build -t go-ks . && \
docker run go-ks
- Add unit tests
-
Refactor for use better practices (structs, interfaces, etc...) - Logging
- Use environment variables
- Refactor struct response
- Graceful shutdown
-
Add GitHub Actions