Update ServerName example a bit

This commit is contained in:
Alex Hultman
2020-09-05 00:00:14 +02:00
parent 92b2d2a736
commit cc27ff5d96
+20 -6
View File
@@ -2,6 +2,8 @@
/* Note that uWS::SSLApp({options}) is the same as uWS::App() when compiled without SSL support */
struct us_listen_socket_t *listenSocket;
int main() {
/* Overly simple hello world app (SNI) */
uWS::SSLApp app = uWS::SSLApp({
@@ -21,13 +23,25 @@ int main() {
}).get("/*", [](auto *res, auto *req) {
res->end("Hello world!");
}).listen(3000, [](auto *token) {
if (token) {
std::cout << "Listening on port " << 3000 << std::endl;
}
}).get("/exit", [](auto *res, auto *req) {
res->end("Shutting down!");
/* We use this to check graceful closedown */
us_listen_socket_close(1, listenSocket);
}).listen(3000, [](auto *listenSocket) {
if (listenSocket) {
std::cout << "Listening on port " << 3000 << std::endl;
::listenSocket = listenSocket;
} else {
std::cout << "Failed to listen on port 3000" << std::endl;
}
});
/* Let's add a wildcard SNI to begin with */
app.addServerName("*.google.*", {
.key_file_name = "../misc/key.pem",
.cert_file_name = "../misc/cert.pem",
.passphrase = "1234"
});
app.run();
std::cout << "Failed to listen on port 3000" << std::endl;
}