A k8s ready http service for QR code generation
- /encode Generate and return qr-code png
- /delete Delete all files
- /files List available files
- /metrics Prometheus metrics endpoint
- /healthy Health check: Readiness
- /healthz Health check: Liveness
$ ./qr_service --help
usage: qr_service [-h] [--listen-address LISTEN_ADDRESS]
[--listen-port LISTEN_PORT] [--disable-delete-files]
[--disable-list-files] [--debug]
optional arguments:
-h, --help show this help message and exit
--listen-address LISTEN_ADDRESS
The address to listen on
--listen-port LISTEN_PORT
The port to listen on
--disable-delete-files
Disable file deletion
--disable-list-files Disable file listing
--debug Show debug output
$ podman run
[output]
A GET request to the /encode endpoint with optional url, size and margin parameters to encode the given URL immediately returns a png encoded image file
$ export LISTEN_ADDRESS=localhost; \
export LISTEN_PORT=44123; \
export URL=https://[::1]; \
export SIZE=20; \
curl -O http://${LISTEN_ADDRESS}:${LISTEN_PORT}/encode?url={${URL}&size=${SIZE}
Generated files land in the static/ directory and can also be fetched from there.
The directory does not get emptied automatically.
A request to /delete removes all png files in this location, if enabled
A call to the /files endpoint returns JSON containing all present png files at the static location
$ export LISTEN_ADDRESS=localhost; \
export LISTEN_PORT=44123; \
curl http://${LISTEN_ADDRESS}:${LISTEN_PORT}/files
A call to the /delete endpoint deletes all present png files at the static location
$ export LISTEN_ADDRESS=localhost; \
export LISTEN_PORT=44123; \
curl http://${LISTEN_ADDRESS}:${LISTEN_PORT}/delete
A /metrics endpoint for Prometheus exists
$ export LISTEN_ADDRESS=localhost; \
export LISTEN_PORT=44123; \
curl http://${LISTEN_ADDRESS}:${LISTEN_PORT}/metrics
bash_unit is used to run the tests
$ make test
./tests/install_bash_unit.sh
bash_unit test framework exists
./bash_unit
./bash_unit tests/test_qr_code_service.sh
Running tests in tests/test_qr_code_service.sh
Starting qr-code-service
Running test_qr_delete... SUCCESS ✓
Running test_qr_encode... SUCCESS ✓
Running test_qr_healthy... SUCCESS ✓
Running test_qr_healthz... SUCCESS ✓
Running test_qr_list... SUCCESS ✓
Running test_qr_service_running... SUCCESS ✓
Stopping qr-code-service (84054)