summaryrefslogtreecommitdiff
path: root/Utility/WebApp.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-28 21:32:18 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-28 21:32:18 -0400
commita763d6dd3e62cea8ccde3091a9874994a1e92dd6 (patch)
tree7a4069b9e1930f4ea9075db7fcc0a1163c89c8cb /Utility/WebApp.hs
parentc597e4ebe25f2ebbc09548fc4607282d1789b523 (diff)
use https when .git/annex/privkey.pem and .git/annex/certificate.pem exist (untested)
I have not managed to generate a key that is accepted by the old version of warp-tls I have here.
Diffstat (limited to 'Utility/WebApp.hs')
-rw-r--r--Utility/WebApp.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/Utility/WebApp.hs b/Utility/WebApp.hs
index 6318abdcf..9d0751502 100644
--- a/Utility/WebApp.hs
+++ b/Utility/WebApp.hs
@@ -17,6 +17,7 @@ import Utility.Hash
import qualified Yesod
import qualified Network.Wai as Wai
import Network.Wai.Handler.Warp
+import Network.Wai.Handler.WarpTLS
import Network.Wai.Logger
import Control.Monad.IO.Class
import Network.HTTP.Types
@@ -70,10 +71,12 @@ browserProc url = proc "xdg-open" [url]
- An IO action can also be run, to do something with the address,
- such as start a web browser to view the webapp.
-}
-runWebApp :: Maybe HostName -> Wai.Application -> (SockAddr -> IO ()) -> IO ()
-runWebApp h app observer = withSocketsDo $ do
+runWebApp :: Maybe TLSSettings -> Maybe HostName -> Wai.Application -> (SockAddr -> IO ()) -> IO ()
+runWebApp tlssettings h app observer = withSocketsDo $ do
sock <- getSocket h
- void $ forkIO $ runSettingsSocket webAppSettings sock app
+ void $ forkIO $
+ (maybe runSettingsSocket (\ts -> runTLSSocket ts) tlssettings)
+ webAppSettings sock app
sockaddr <- fixSockAddr <$> getSocketName sock
observer sockaddr