|
1 |
| -# example-consul [](https://dev.azure.com/lganzzzo/lganzzzo/_build?definitionId=15&branchName=master) |
| 1 | +# Consul Integration Example [](https://dev.azure.com/lganzzzo/lganzzzo/_build?definitionId=15&branchName=master) |
| 2 | + |
| 3 | +Example project how-to use [oatpp-consul](https://github.com/oatpp/oatpp-consul) module. |
| 4 | + |
| 5 | +#### More about oat++: |
| 6 | +- Website: [https://oatpp.io](https://oatpp.io) |
| 7 | +- Docs: [https://oatpp.io/docs/start](https://oatpp.io/docs/start) |
| 8 | +- Oat++ Repo: [https://github.com/oatpp/oatpp](https://github.com/oatpp/oatpp) |
| 9 | + |
| 10 | +## Overview |
| 11 | +This project is using `oatpp` and `oatpp-consul` modules. |
| 12 | + |
| 13 | +Currently this is trivial example.- Read/Write from/to Consul KV via endpoints declared in Controller. |
| 14 | +More complex example later. |
| 15 | + |
| 16 | +In this example Consul is expected to run at port 8500. |
| 17 | + |
| 18 | +### Project layout |
| 19 | + |
| 20 | +``` |
| 21 | +
|
| 22 | +- CMakeLists.txt // project loader script. load and build dependencies |
| 23 | +- main/ // main project directory |
| 24 | + | |
| 25 | + |- CMakeLists.txt // projects CMakeLists.txt |
| 26 | + |- src/ // source folder |
| 27 | + |- test/ // test folder |
| 28 | + |
| 29 | +``` |
| 30 | +``` |
| 31 | +- src/ |
| 32 | + | |
| 33 | + |- controller/ // Folder containing controller where all endpoints are declared |
| 34 | + |- dto/ // DTOs are declared here |
| 35 | + |- AppComponent.hpp // Service config |
| 36 | + |- Logger.hpp // Application Logger |
| 37 | + |- App.cpp // main() is here |
| 38 | + |
| 39 | +``` |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +### Build and Run |
| 44 | + |
| 45 | +#### Using CMake |
| 46 | + |
| 47 | +``` |
| 48 | +$ mkdir build && cd build |
| 49 | +$ cmake .. |
| 50 | +$ make run ## Download, build, and install all dependencies. Run project |
| 51 | +
|
| 52 | +``` |
| 53 | + |
| 54 | +#### In Docker |
| 55 | + |
| 56 | +``` |
| 57 | +$ docker build -t example-consul . |
| 58 | +$ docker run -p 8000:8000 -t example-consul |
| 59 | +``` |
0 commit comments