diff options
author | 2013-01-09 23:17:52 -0400 | |
---|---|---|
committer | 2013-01-09 23:18:00 -0400 | |
commit | b806e8e4d10c428025e23ce501b14380b821735d (patch) | |
tree | 3851a9ca29767bad122149a9acc86d2aac51061f /Assistant/Threads/WebApp.hs | |
parent | 6a46afb5a7280e70ace7487019c710a579657d80 (diff) |
webapp: Use IP address, rather than localhost
since some systems may have configuration problems or other issues that
prevent web browsers from connecting to the right localhost IP for the
webapp.
Tested on both ipv4 and ipv6 localhost. Url for the latter looks like:
http://[::1]:50676
Diffstat (limited to 'Assistant/Threads/WebApp.hs')
-rw-r--r-- | Assistant/Threads/WebApp.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Assistant/Threads/WebApp.hs b/Assistant/Threads/WebApp.hs index 5ac36f698..c4c9fa87a 100644 --- a/Assistant/Threads/WebApp.hs +++ b/Assistant/Threads/WebApp.hs @@ -35,7 +35,7 @@ import Git import Yesod import Yesod.Static -import Network.Socket (PortNumber) +import Network.Socket (SockAddr) import Data.Text (pack, unpack) thisThread :: String @@ -67,14 +67,14 @@ webAppThread assistantdata urlrenderer noannex postfirstrun onstartup = thread $ ( return $ httpDebugLogger app , return app ) - runWebApp app' $ \port -> if noannex + runWebApp app' $ \addr -> if noannex then withTempFile "webapp.html" $ \tmpfile _ -> - go port webapp tmpfile Nothing + go addr webapp tmpfile Nothing else do let st = threadState assistantdata htmlshim <- runThreadState st $ fromRepo gitAnnexHtmlShim urlfile <- runThreadState st $ fromRepo gitAnnexUrlFile - go port webapp htmlshim (Just urlfile) + go addr webapp htmlshim (Just urlfile) where thread = NamedThread thisThread getreldir @@ -82,13 +82,13 @@ webAppThread assistantdata urlrenderer noannex postfirstrun onstartup = thread $ | otherwise = Just <$> (relHome =<< absPath =<< runThreadState (threadState assistantdata) (fromRepo repoPath)) - go port webapp htmlshim urlfile = do - let url = myUrl webapp port + go addr webapp htmlshim urlfile = do + let url = myUrl webapp addr maybe noop (`writeFileProtected` url) urlfile writeHtmlShim "Starting webapp..." url htmlshim maybe noop (\a -> a url htmlshim) onstartup -myUrl :: WebApp -> PortNumber -> Url -myUrl webapp port = unpack $ yesodRender webapp urlbase HomeR [] +myUrl :: WebApp -> SockAddr -> Url +myUrl webapp addr = unpack $ yesodRender webapp urlbase HomeR [] where - urlbase = pack $ "http://localhost:" ++ show port + urlbase = pack $ "http://" ++ show addr |