// needs a function O webServe(S uri, SS params) { ... } // and a function newWebSocket() switchable int httpPort = 80; switchable int httpsPort = 443; transient autoDispose WebSocketHTTPD httpServer; transient autoDispose WebSocketHTTPD httpsServer; switchable bool redirectHttpToHttps; transient new HTTPSpamBlocker1 spamBlocker; void start_webServers(File keyStore, S passphrase) { start_webServers(serveHttps_makeSSLSocketFactory(keyStore, passphrase)); } void start_webServers(SSLServerSocketFactory sslSocketFactory) ctex { if (httpPort != 0) pcall { WebSocketHTTPD _httpServer = new(httpPort, lambda1 newWebSocket); _httpServer.enter = lambda0 enter; _httpServer.serveFunction = func(S uri, SS parms) { redirectHttpToHttps && !startsWith(uri, "/.well-known/") ? serveRedirect("https://" + serveHttp_domainName() + (httpsPort == 443 ? "" : ":" + httpsPort) + uri) : webServe(uri, parms) }; _httpServer.start(); print("HTTP server started on port " + _httpServer.getPort()); httpServer = _httpServer; } if (httpsPort == 0 || sslSocketFactory == null) ret; pcall { WebSocketHTTPD _httpsServer = new(httpsPort, lambda1 newWebSocket); _httpsServer.enter = lambda0 enter; _httpsServer.makeSecure(sslSocketFactory); _httpsServer.serveFunction = func(S uri, SS parms) { webServe(uri, parms) }; _httpsServer.start(); print("HTTPS server started on port " + _httpsServer.getPort()); httpsServer = _httpsServer; } } Cl<WebSocketHTTPD> webServers() { ret llNotNulls(httpServer, httpsServer); }
Began life as a copy of #1027628
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029492 |
Snippet name: | HTTP+HTTPS Server Include for DynModules [WebSocket version] |
Eternal ID of this version: | #1029492/14 |
Text MD5: | b3d22107ff9165928480c762a275b536 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-04-17 19:39:29 |
Source code size: | 1638 bytes / 43 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 294 / 836 |
Version history: | 13 change(s) |
Referenced in: | #1028671 - Eleu Cruddie [old] #1029543 - DynEleu [web server as module] #1029617 - Eleu 3 [backup before DynEleu] |