missingServerName and updated ServerName example

This commit is contained in:
Alex Hultman
2020-08-17 05:39:14 +02:00
parent 77aced05f8
commit f69282c478
4 changed files with 32 additions and 7 deletions
+15 -6
View File
@@ -4,21 +4,30 @@
int main() {
/* Overly simple hello world app (SNI) */
uWS::SSLApp({
.key_file_name = "../misc/key.pem",
.cert_file_name = "../misc/cert.pem",
.passphrase = "1234"
}).addServerName("localhost", {
uWS::SSLApp app = uWS::SSLApp({
.key_file_name = "../misc/key.pem",
.cert_file_name = "../misc/cert.pem",
.passphrase = "1234"
}).missingServerName([&app](const char *hostname) {
printf("We are missing server name: <%s>\n", hostname);
/* Assume it is localhost, so add it */
app.addServerName("localhost", {
.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();
});
app.run();
std::cout << "Failed to listen on port 3000" << std::endl;
}