sunn 65bad61abb [Qt5 Server] Add Support for Qt5 server using QHttpEngine (#322)
* Initial wiring to get the QHttpEngine Server running for Qt5 server

* Add wiring for build environment

* Add current generated files

* Update README.md

* Solved Build for Docker and Host
Wired up main
TODO : Route API call to handlers

* Wire up routes

* Wiring up routes update

* Convert Path to QHttpEngine format

* Rename some files

* Extract query Parameters and path parameters

* Removed pri file, Qt can read CMakeLists.txt

* Initial support of deserialization

* Adding initial support for response serialization

* Setup simple signal handler to quite the server with Ctrl+C in a container and on the host

* Remove unneeded function

* Add executable permission to script and move from Debian to Alpine for Dockerfile

* Add stringValue of missing types

* Unify toJson'xxx' APIs the same way like setValue

* Rework to remove all pointer usages, pass by const references, simplify model, add emit signals to default handlers
2018-07-26 18:30:13 +08:00
..

Qt5 HTTP Server based on the Qhttpengine

This server was generated by the [openapi-generator] (https://openapi-generator.tech) project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.

To see how to make this your own, look here:

README

  • API version: 1.0.0

QHTTPEngine

Build Status MIT License

Simple set of classes for developing HTTP server applications in Qt.

Documentation

To learn more about building and using the library, please visit this page:

https://ci.quickmediasolutions.com/job/qhttpengine-documentation/doxygen/

Viewing the code

You can view the code using an editor like Microsoft Visual Studio Code or you can Use QtCreator and browse for the root CMakeLists.txt and load it as a project

Build with make

Install the tools [Linux/Debian]

sudo apt install cmake build-essential libssl-dev qtbase5-dev qtbase5-dev-tools git curl

To build, go to the server folder

make 

To run the server

./build/src/cpp-qt5-server &

Invoke an API

curl -X GET    http://localhost:8080/v2/store/inventory
curl -X POST   http://localhost:8080/v2/store/order   -H "Content-Type: application/json" -d "{ \"id\": 22, \"petId\": 1541, \"quantity\": 5, \"shipDate\": \"2018-06-16T18:31:43.870Z\", \"status\": \"placed\", \"complete\": \"true\" }"
curl -X GET    http://localhost:8080/v2/pet/findByStatus
curl -X GET    http://localhost:8080/v2/store/inventory

Run and build with docker

Building with docker multistage If you dont have docker install here Add yourself to the docker group

docker build --network=host -t cpp-qt5-server .

Running with docker

docker run --rm -it --name=server-container cpp-qt5-server 

Invoking an API

Mind the IP here

curl -X GET   http://172.17.0.2:8080/v2/store/inventory
curl -X POST  http://172.17.0.2:8080/v2/store/order -H "Content-Type: application/json" -d "{ \"id\": 22, \"petId\": 1541, \"quantity\": 5, \"shipDate\": \"2018-06-16T18:31:43.870Z\", \"status\": \"placed\", \"complete\": \"true\" }"

use this command to get the container IP

docker inspect server-container | grep "IPAddress"

To exit from the command line

Ctrl + p + q

To stop container

docker stop <containername>

or to terminate and quit

Ctrl+C