A REST API implementation of Fizzbuzz.
The original fizz-buzz consists in writing all numbers from 1 to 100, and just replacing all multiples of 3 by "fizz", all multiples of 5 by "buzz", and all multiples of 15 by "fizzbuzz". The output would look like this: "1,2,fizz,4,buzz,fizz,7,8,fizz,buzz,11,fizz,13,14,fizzbuzz,16,...".
In this version, the endpoint /v1/fizzbuzz
accepts five parameters : three integers int1
, int2
and limit
, and two strings str1
and str2
and returns a list of strings with numbers from 1 to limit, where: all multiples of int1 are replaced by str1, all multiples of int2 are replaced by str2, all multiples of int1 and int2 are replaced by str1str2.
example:
# Run the server locally before using: make build && ./out/bin/fizzbuzz
curl 'http://localhost:8080/v1/fizzbuzz?int1=3&int2=5&limit=16&str1=fizz&str2=buzz'
This section describes the repository folders:
config
: application config is handled using a yaml file that is parsed with the viper library. The default file is theconfig.yaml
one that could be overwritten by setting theCONFIG_PATH
environment variablerouter
: defines the http server routers and middlewares based on go-chi libraryhandlers
: implements the function handler of each server endpointtelemetry
: configures application logger, tracer and metertelemetry/logger
: application logger uses the zap librarytelemetry/tracer
: tracer exporter and provider pipeline are created using the opentelemetry sdk. Server request spans are generated using the httptracer go-chi middlewaretelemetry/meter
: exposes server runtime metrics on:8082/metrics
endpoint. These metrics could be scrapped by prometheuschart
: contains a helm chart used to deploy the application in a kubernetes cluster