From 61a66c324a71bab68907083da309f2ca63e04bdd Mon Sep 17 00:00:00 2001 From: Connor Prussin Date: Tue, 1 Aug 2017 21:43:14 -0700 Subject: [PATCH] Move to upstream `purescript-node-http`. (#59) Move to upstream `purescript-node-http` --- bower.json | 4 ++-- src/HTTPure/Server.purs | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index f48642d..30da656 100644 --- a/bower.json +++ b/bower.json @@ -18,9 +18,9 @@ ], "dependencies": { "purescript-prelude": "^3.0.0", - "purescript-node-http": "cprussin/purescript-node-http#dd87dbaec43ffc5312b78b10316023dc7b78a06d", "purescript-aff": "^3.1.0", - "purescript-node-fs": "^4.0.0" + "purescript-node-fs": "^4.0.0", + "purescript-node-http": "^4.1.0" }, "devDependencies": { "purescript-psci-support": "^3.0.0", diff --git a/src/HTTPure/Server.purs b/src/HTTPure/Server.purs index 0098c5b..1d0f20c 100644 --- a/src/HTTPure/Server.purs +++ b/src/HTTPure/Server.purs @@ -13,6 +13,7 @@ import Data.Options ((:=)) import Node.Encoding as Encoding import Node.FS.Sync as FSSync import Node.HTTP as HTTP +import Node.HTTP.Secure as HTTPS import HTTPure.HTTPureM as HTTPureM import HTTPure.Request as Request @@ -60,11 +61,14 @@ bootHTTPS :: forall e. ServerM e -> ServerM e bootHTTPS options cert key router onStarted = do - certText <- FSSync.readTextFile Encoding.UTF8 cert - keyText <- FSSync.readTextFile Encoding.UTF8 key - let sslOptions = HTTP.key := keyText <> HTTP.cert := certText - HTTP.createServerS sslOptions (handleRequest router) >>= \server -> - HTTP.listen server options onStarted + cert' <- FSSync.readTextFile Encoding.UTF8 cert + key' <- FSSync.readTextFile Encoding.UTF8 key + server <- HTTPS.createServer (sslOpts key' cert') (handleRequest router) + HTTP.listen server options onStarted + where + sslOpts key' cert' = + HTTPS.key := HTTPS.keyString key' <> + HTTPS.cert := HTTPS.certString cert' -- | Given a port number, return a HTTP.ListenOptions Record. listenOptions :: Int -> HTTP.ListenOptions