Niklas Fiekas e927db7979 Bump minimum CMake version to 3.10 7 months ago
..
client a268f2fe07 mg_connect_client should set SNI for HTTPS connections 3 years ago
embed_certificate e037c4e850 Interface change: struct mg_error_data 3 years ago
embedded_c d9c3087e3e spelling: Fix examples/* issues. 2 years ago
embedded_cpp 4cca3fb108 Allow WITH_ZLIB in example Makefile 4 years ago
https 68479acb5f fallback_document_root and fallback_websocket_root initial implementation 2 years ago
linux_ws_server_cpp e927db7979 Bump minimum CMake version to 3.10 7 months ago
multidomain 4378fdc73b Support multiple domains (Step 10/?) 7 years ago
rest d9c3087e3e spelling: Fix examples/* issues. 2 years ago
ws_client 19b5f8a6a0 + Fixed typos 6 years ago
ws_server d41158bb3a Add websocket server example, fix issue with WS subprotocol 3 years ago
README.md 556821b516 Document/Comment example for embedding the certificate into the C source 3 years ago

README.md

Examples

The (embedded_c) example shows how to embed civetweb into a C or C++ application.

The (embedded_cpp) example demonstrates embedding in a C++ application. It uses the C++ wrapper of the full C interface civetweb.h. The C++ wrapper only offers a limited subset of the full C API. Thus, the C example is more complete than the C++ example.

These examples were not designed with security in mind, but to show how the API can be used in principle. For more information, see the documentation. Some examples can also be found in the test folder, but they are less documented and adapted to some special needs of the test frameworks.

The (https) example shows how to configure a HTTPS server with improved security settings. It does not hold any source, but only a configuration file and some documentation how to use it.

The (embed_certificate) example shows embed civetweb in a C application without using additional files on the disk. The HTTPS certificate is directly embedded in the code and all content is generated by a callback. It is a template for using civetweb on (embedded) devices without a file system - or for systems that do not want CivetWeb to access the disk.

The multidomain example demonstrates how to host multiple domains with different HTTPS certificates. It uses the standalone server (civetweb.c + main.c) and existing certificates.

The ws_client example shows how to use the websocket client interface to communicate with an (external) websocket server. It uses the "echo demo" of websocket.org and will work only if this server is reachable.

All examples are subject to the MIT license (unless noted otherwise) - they come without warranty of any kind.

Note that the examples are only meant as a demonstration how to use CivetWeb. The example codes are omitting some error checking and input validation for better readability of the source. They are not as actively maintained and continuously developed as main source of the project (include/civetweb.h, src/civetweb.c, src/*.inl).
Example codes undergo less quality management than the main source files of this project. Examples are not checked and updated with every new version. There are no repeated security assessment for the example codes, settings are not updated on a regular basis.

Contributions to examples code are welcome, under the same conditions as contributions to the main source code (Contribution.md).