Small C++ HTTP service built with Boost.Beast + CMake.
The project exposes a minimal REST API to store and retrieve text documents on disk.
- Clean separation of concerns:
http/services/repository - Async HTTP server using Boost.Beast
- Interface-based persistence (
DocumentRepository) with file implementation - Easy local build with CMake and Make
- Dockerized runtime for reproducible runs
src/
http/ # Server, routing, request/response mapping, controllers
services/ # Business logic (counter, document management)
repository/ # Persistence abstraction and file implementation
main.cpp # Program entrypoint
- Linux/macOS
- C++17 compiler
- CMake >= 3.15
- Boost (
system,filesystem) - nlohmann/json headers
On Ubuntu/Debian (example):
sudo apt update
sudo apt install -y build-essential cmake libboost-all-dev nlohmann-json3-devmake clean && make
./build/docsforyou 127.0.0.1 8080Base URL:
http://127.0.0.1:8080
GET /count→ HTML with request counterGET /time→ HTML with current epoch time
Example:
curl -i http://127.0.0.1:8080/count
curl -i http://127.0.0.1:8080/timePOST /doccreates a documentGET /doc/{id}fetches one documentDELETE /doc/{id}deletes one document
Create:
curl -i -X POST http://127.0.0.1:8080/doc \
-H "Content-Type: application/json" \
-d '{"author":"alice","content":"hello world"}'Expected response:
{"id":"0"}Read:
curl -i http://127.0.0.1:8080/doc/0Delete:
curl -i -X DELETE http://127.0.0.1:8080/doc/0Build image:
make docker-buildRun container (maps host 8080 to container 8080):
make docker-runThis command mounts ./data from your host into /app in the container, so *.DFY files persist across restarts.
Stop container:
make docker-stopTail logs:
make docker-logsOverride defaults:
make docker-build IMAGE_NAME=docsforyou:v1
make docker-run IMAGE_NAME=docsforyou:v1 CONTAINER_NAME=docsforyou-dev PORT=9090
make docker-run DATA_DIR=$PWD/my-docs-data- Documents are currently stored in the process working directory as
*.DFYfiles. - IDs are numeric and generated incrementally.
- On systems where Docker requires elevated permissions, add your user to the
dockergroup or run Docker commands with sudo.
- Add automated tests (service and routing layers)
- Add request validation and consistent JSON error bodies
- Add configurable data directory via env var or CLI
- Add CI (build + test) workflow