From 6be58309b84711b592901fa7394f316a68985af9 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Mon, 3 Oct 2022 19:14:42 +0200 Subject: [PATCH] addServerName should do nothing in non-SSL --- src/App.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/App.h b/src/App.h index 00a8ccb..34d3a42 100644 --- a/src/App.h +++ b/src/App.h @@ -104,10 +104,14 @@ public: /* Server name */ TemplatedApp &&addServerName(std::string hostname_pattern, SocketContextOptions options = {}) { - /* First we create a new router for this domain */ - auto *domainRouter = new HttpRouter::RouterData>(); + /* Do nothing if not even on SSL */ + if constexpr (SSL) { + /* First we create a new router for this domain */ + auto *domainRouter = new HttpRouter::RouterData>(); + + us_socket_context_add_server_name(SSL, (struct us_socket_context_t *) httpContext, hostname_pattern.c_str(), options, domainRouter); + } - us_socket_context_add_server_name(SSL, (struct us_socket_context_t *) httpContext, hostname_pattern.c_str(), options, domainRouter); return std::move(*this); }