This project implements a RESTful API server in C++. It utilizes SQLite for database management, JSON for data exchange, and Boost libraries for enhanced performance. The server is designed to run on Ubuntu and is containerized using Docker for easy setup and deployment.
Before you begin, ensure you have Docker installed on your machine. If you prefer to run the server natively, you will need:
- Ubuntu 22.04
- CMake and Make
- g++ or another C++ compiler
- SQLite, Boost, Served and JSONCpp libraries
To install the necessary libraries on Ubuntu, run:
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install g++
sudo apt-get install cmake
sudo apt-get install make
sudo apt-get install sqlite3 libsqlite3-dev
sudo apt-get install libjsoncpp-dev
sudo apt-get install libboost-all-dev
sudo apt-get install git
git clone https://github.com/meltwater/served.git \
&& mkdir served/build && cd served/build \
&& cmake .. && make && make install
To build and run the server using Docker, no additional installation steps are required apart from having Docker installed.
-
Extract project from compressed tar archive
-
Build the project using CMake:
mkdir build
cd build
cmake ..
make
- Build the Docker image for the server:
docker build -t device-server .
After building the project, you can run the server with:
./build/server
Start the server in a Docker container:
docker run -p 8080:8080 device-server
Interact with the server using HTTP client tools like curl
. Example API calls:
curl -X GET http://0.0.0.0:8080/devices
curl -X POST http://0.0.0.0:8080/locations -H "Content-Type: application/json" -d '{"name": "Main Office", "type": "Office"}'