mirror of
https://github.com/typeable/wai.git
synced 2025-01-07 06:36:36 +03:00
Merge pull request #539 from simonmichael/master
make host configurable too (fixes #538)
This commit is contained in:
commit
f0fac18e48
@ -5,6 +5,7 @@ module Network.Wai.Handler.Launch
|
||||
( run
|
||||
, runUrl
|
||||
, runUrlPort
|
||||
, runHostPortUrl
|
||||
) where
|
||||
|
||||
import Network.Wai
|
||||
@ -13,6 +14,7 @@ import Network.HTTP.Types
|
||||
import qualified Network.Wai.Handler.Warp as Warp
|
||||
import Data.IORef
|
||||
import Data.Monoid (mappend)
|
||||
import Data.String (fromString)
|
||||
import Control.Concurrent (forkIO, threadDelay)
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
import Control.Monad (unless)
|
||||
@ -186,12 +188,15 @@ runUrl :: String -> Application -> IO ()
|
||||
runUrl = runUrlPort 4587
|
||||
|
||||
runUrlPort :: Int -> String -> Application -> IO ()
|
||||
runUrlPort port url app = do
|
||||
runUrlPort = runHostPortUrl "*4"
|
||||
|
||||
runHostPortUrl :: String -> Int -> String -> Application -> IO ()
|
||||
runHostPortUrl host port url app = do
|
||||
x <- newIORef True
|
||||
_ <- forkIO $ Warp.runSettings
|
||||
( Warp.setPort port
|
||||
$ Warp.setOnException (\_ _ -> return ())
|
||||
$ Warp.setHost "*4" Warp.defaultSettings)
|
||||
$ Warp.setHost (fromString host) Warp.defaultSettings)
|
||||
$ ping x app
|
||||
launch port url
|
||||
loop x
|
||||
|
Loading…
Reference in New Issue
Block a user