summaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-08 15:04:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-08 15:04:35 -0400
commite2057f41f7dfc22ad85b0e087f42364f21bf7fbd (patch)
tree19769bf97ca9263d814be6a54b8af51e599702bd /Assistant/Threads
parenta664ee5e45a57713d5b47d9fa592e78881994055 (diff)
webapp: New --listen= option allows running the webapp on one computer and connecting to it from another.
Does not yet use HTTPS. I'd need to generate a certificate, and I'm not sure what's the best way to do that.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/WebApp.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/Assistant/Threads/WebApp.hs b/Assistant/Threads/WebApp.hs
index b7bfd0c4a..6fadd7be7 100644
--- a/Assistant/Threads/WebApp.hs
+++ b/Assistant/Threads/WebApp.hs
@@ -38,7 +38,7 @@ import Git
import Yesod
import Yesod.Static
-import Network.Socket (SockAddr)
+import Network.Socket (SockAddr, HostName)
import Data.Text (pack, unpack)
mkYesodDispatch "WebApp" $(parseRoutesFile "Assistant/WebApp/routes")
@@ -49,10 +49,11 @@ webAppThread
:: AssistantData
-> UrlRenderer
-> Bool
+ -> Maybe HostName
-> Maybe (IO String)
-> Maybe (Url -> FilePath -> IO ())
-> NamedThread
-webAppThread assistantdata urlrenderer noannex postfirstrun onstartup = thread $ liftIO $ do
+webAppThread assistantdata urlrenderer noannex listenhost postfirstrun onstartup = thread $ liftIO $ do
webapp <- WebApp
<$> pure assistantdata
<*> (pack <$> genRandomToken)
@@ -60,13 +61,14 @@ webAppThread assistantdata urlrenderer noannex postfirstrun onstartup = thread $
<*> pure $(embed "static")
<*> pure postfirstrun
<*> pure noannex
+ <*> pure listenhost
setUrlRenderer urlrenderer $ yesodRender webapp (pack "")
app <- toWaiAppPlain webapp
app' <- ifM debugEnabled
( return $ httpDebugLogger app
, return app
)
- runWebApp app' $ \addr -> if noannex
+ runWebApp listenhost app' $ \addr -> if noannex
then withTempFile "webapp.html" $ \tmpfile _ ->
go addr webapp tmpfile Nothing
else do