Skip to content

Commit

Permalink
Fix #450 - redirect HTTP to HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed May 22, 2017
1 parent 56f66fe commit 1814638
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ shared static this()
.registerRestInterface(new ApiV1(execProvider, contentProvider))
.get("/static/*", serveStaticFiles(publicDir.buildPath("static"), fsettings));

listenHTTP(settings, urlRouter);
listenHTTP(httpsSettings, urlRouter);
if (startHTTPS) {
// redirect all HTTP to HTTPS
listenHTTP(settings, (req, res) {
auto url = req.fullURL;
url.schema = "https";
res.redirect(url);
});
listenHTTP(httpsSettings, urlRouter);
} else {
listenHTTP(settings, urlRouter);
}
}

0 comments on commit 1814638

Please sign in to comment.