From 91a7a44eeace0f185fe3a479fe991007f6622571 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Mon, 25 Nov 2019 21:24:29 +0100 Subject: [PATCH] Add SSL example --- examples/HelloWorldSSL.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/HelloWorldSSL.cpp diff --git a/examples/HelloWorldSSL.cpp b/examples/HelloWorldSSL.cpp new file mode 100644 index 0000000..14190e7 --- /dev/null +++ b/examples/HelloWorldSSL.cpp @@ -0,0 +1,20 @@ +#include "App.h" + +/* Note that uWS::SSLApp({options}) is the same as uWS::App() when compiles without SSL support */ + +int main() { + /* Overly simple hello world app */ + uWS::SSLApp({ + .key_file_name = "../misc/key.pem", + .cert_file_name = "../misc/cert.pem", + .passphrase = "1234" + }).get("/*", [](auto *res, auto *req) { + res->end("Hello world!"); + }).listen(3000, [](auto *token) { + if (token) { + std::cout << "Listening on port " << 3000 << std::endl; + } + }).run(); + + std::cout << "Failed to listen on port 3000" << std::endl; +}