Hi, This code is based on the Microsoft open source project cpprestSDK. It works with MariaDB and communicates with the client in a Json way. It also supports Https and was created using boost's ssl library. Certificate generation was created using openssl.
When making a request to the server in Json, send it as ""(String). If you want to process data with a type other than String, modify the code.
Json example
{"id" : 1}
-> X
{"id" : "1"}
-> O
Here is my sample code. My samplecode
If you want a reference to cpprestSDK here. Cpprestful reference
Platfrom : Docker
OS : Ubuntu 20.04
Compiler : GCC/G++
DB : MariaDB
Code editor : Visual Studio Code
Install cpprestSDK if you want to use that code.
With apt-get on Debian/Ubuntu
$ sudo apt-get install libcpprest-dev
Install MariaDB
$ sudo apt-get install libmariadb-dev
$ sudo apt-get install libmysqlclient-dev
1. MariaDB service start.
$ service mysql restart
2. stdafx.hpp compile
$ sudo ./build_hpp.sh
3. Modify the main.cpp code.
In the main.cpp code, you need to set it according to your DB table environment.
Part Part is mariaID
and elements of mytable_list
4. MakeFile
$ make
5. Start server!!
$ sudo ./start.exe
If you are working with curl, use http for the server.
GET request
$ curl -X GET http://localhost:10022
POST request
$ curl -d '{"id":"1", "name":"hwan", "start_year":"2020-08-23", "end_year":"2020-08-23", "img":" ", "text":"test"}' -H "Content-Type: application/json" -X POST http://localhost:10022
PUT request
$ curl -d '{"id":"1", "name":"Hong", "img":" ", "text":"Hello word!!"}' -H "Content-Type: application/json" -X PUT http://localhost:10022
DELETE request
$ curl -d '{"id":"1"}' -H "Content-Type: application/json" -X DELETE http://localhost:10022
Thanks!!