Simple C++ application that interacts with different open api's to create text that you can receive on GET endpoints. See swagger.yml
Uses vcpkg to handle dependencies and cmake build system. It uses nlohmann_json for json, drogon for http server part, cpr for http client part, spdlog for logging and gtest for testing.
Testing is done using gtest. Testing of the classes Funny and Service are done using dependency injection. Mocking of the client and server classes are done using googlemock.
- Install vcpkg
$ git clone ssh://[email protected]/microsoft/vcpkg
$ cd vcpkg
$ ./bootstrap-vcpkg.sh
- Install dependencies
$ ./vcpkg install nlohmann_json gtest spdlog drogon cpp-httplib
- set VCPKG_ROOT environment variable
$ export VCPKG_ROOT=/path/to/vcpkg
Create a build directory if you haven't already and initailize the dependencies:
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug
cd ..
cmake --build build
./build/bin/funny
The tests are automatically run after each build. You can run them by invoking:
./build/bin/funnytests
docker-compose build
docker-compose up -d
The tests are also run after building in docker. To run the tests in docker invoke:
docker run cpp-funny-endpoints funnytests
See k8s/README.md.
$ curl http://localhost:5000/v1/advice
{"message":"If you don't want something to be public, don't post it on the Internet."}
$ curl http://localhost:5000/v1/chucknorris
{"message":"there is no use crying over spilled milk, unless its Chuck Norris' milk because then your gonna die"}
$ curl http://localhost:5000/v1/dadjoke
{"message":"What do you call an eagle who can play the piano? Talonted!"}
$ curl http://localhost:5000/v1/random
{"message":"Advice: When painting a room, preparation is key. The actual painting should account for about 40% of the work."}