// needs a function O webServe(S uri, SS params) { ... } switchable int httpPort = 80; switchable int httpsPort = 443; transient autoDispose MyHTTPD httpServer; transient autoDispose MyHTTPD httpsServer; transient 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) { httpServer = new MyHTTPD(httpPort); 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()); } if (httpsPort == 0 || sslSocketFactory == null) ret; httpsServer = new MyHTTPD(httpsPort); 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()); }
Began life as a copy of #1026245
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: | #1027628 |
| Snippet name: | HTTP+HTTPS Server Include for DynModules |
| Eternal ID of this version: | #1027628/13 |
| Text MD5: | 448e968fbaf4b5c3058e9db60e276d7d |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-07-05 13:22:33 |
| Source code size: | 1342 bytes / 36 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 467 / 1352 |
| Version history: | 12 change(s) |
| Referenced in: | [show references] |