QHttpEngine 0.1.0
Simple and secure HTTP server for Qt applications
|
QHttpEngine provides a simple set of classes for developing HTTP server applications in Qt.
The design goals of QHttpEngine include:
All of QHttpEngine's functionality is included in a single monolithic library.
QHttpEngine has been tested on the following combinations of compiler and operating system:
QHttpEngine is designed in a portable way, so it may run on other compilers and operating systems than the ones listed above. However, the list represents the combinations that are actively tested and officially supported.
QHttpEngine uses CMake for building the library. The library recognizes four options during configuration, all of which are disabled by default (the library is built as a shared library):
BUILD_STATIC
- build and link a static library instead of a shared libraryBUILD_DOC
- (requires Doxygen) generates documentation from the comments in the source codeBUILD_EXAMPLES
- builds the sample applications that demonstrate how to use QHttpEngineBUILD_TESTS
- build the test suiteIt is also possible to override installation directories by customizing the BIN_INSTALL_DIR
, LIB_INSTALL_DIR
, INCLUDE_INSTALL_DIR
, CMAKECONFIG_INSTALL_DIR
, DOC_INSTALL_DIR
, and EXAMPLES_INSTALL_DIR
variables.
Serving static files from a directory is as simple as creating an instance of QHttpServer and QFilesystemHandler:
QHttpEngine can also be used to easily add an HTTP API to an existing application by deriving a class from QObjectHandler. Each signal that takes a single QVariantMap parameter and returns a QVariantMap can be directly invoked by using its name in the request path. For example:
A client can send a POST request to /doSomething
with JSON data and receive the response from the slot directly as JSON data. The chatserver example provides a demonstration of this.