on master help sign in
Merge branch 'wai-0.4'

Conflicts: wai-handler-launch/wai-handler-launch.cabal

commite08ae69baae35bb588faa0e771f1eeeebd0a5787 authorMichael <michael@snoyman.com> dateThu 5 Jan 2012, 12:21 (15 years ago) parent36722c84135032
2 files changed+11−8
wai-handler-launch/Network/Wai/Handler/Launch.hs+11−7 wai-handler-launch/wai-handler-launch.cabal−1
wai-handler-launch/Network/Wai/Handler/Launch.hs+11−7
@@ -4,6 +4,7 @@
44module Network.Wai.Handler.Launch
55 ( run
66 , runUrl
7+ , runUrlPort
78 ) where
89
910import Network.Wai
@@ -105,32 +106,35 @@ foreign import ccall "launch"
105106 launch' :: Int -> CString -> IO ()
106107#endif
107108
108−launch :: String -> IO ()
109+launch :: Int -> String -> IO ()
109110
110111#if WINDOWS
111−launch s = withCString s $ launch' 4587
112+launch port s = withCString s $ launch' port
112113#else
113−launch s = forkIO (rawSystem
114+launch port s = forkIO (rawSystem
114115#if MAC
115116 "open"
116117#else
117118 "xdg-open"
118119#endif
119− ["http://127.0.0.1:4587/" ++ s] >> return ()) >> return ()
120+ ["http://127.0.0.1:" ++ show port ++ "/" ++ s] >> return ()) >> return ()
120121#endif
121122
122123run :: Application -> IO ()
123124run = runUrl ""
124125
125126runUrl :: String -> Application -> IO ()
126−runUrl url app = do
127+runUrl = runUrlPort 4587
128+
129+runUrlPort :: Int -> String -> Application -> IO ()
130+runUrlPort port url app = do
127131 x <- newIORef True
128132 _ <- forkIO $ Warp.runSettings Warp.defaultSettings
129− { Warp.settingsPort = 4587
133+ { Warp.settingsPort = port
130134 , Warp.settingsOnException = const $ return ()
131135 , Warp.settingsHost = "127.0.0.1"
132136 } $ ping x app
133− launch url
137+ launch port url
134138 loop x
135139
136140loop :: IORef Bool -> IO ()
wai-handler-launch/wai-handler-launch.cabal−1
@@ -1,4 +1,3 @@
1−Name: wai-handler-launch
21Version: 1.0.0
32Synopsis: Launch a web app in the default browser.
43Description: This handles cross-platform launching and inserts Javascript code to ping the server. When the server no longer receives pings, it shuts down.