Permalink
Browse files

warpEnv

  • Loading branch information...
1 parent 48357a6 commit 8793cffe471c5f5deb903bd215e086cab167e4f8 @snoyberg snoyberg committed Sep 24, 2012
Showing with 18 additions and 2 deletions.
  1. +1 −1 yesod-form/yesod-form.cabal
  2. +16 −0 yesod/Yesod.hs
  3. +1 −1 yesod/yesod.cabal
@@ -1,5 +1,5 @@
name: yesod-form
-version: 1.1.2
+version: 1.1.3
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
View
@@ -10,6 +10,7 @@ module Yesod
-- * Running your application
, warp
, warpDebug
+ , warpEnv
, develServer
-- * Commonly referenced functions/datatypes
, Application
@@ -58,6 +59,8 @@ import Text.Blaze.Html (toHtml)
import Text.Blaze (toHtml)
#endif
+import System.Environment (getEnv)
+
showIntegral :: Integral a => a -> String
showIntegral x = show (fromIntegral x :: Integer)
@@ -80,6 +83,19 @@ warpDebug port app = do
waiApp <- toWaiApp app
run port $ logStdout waiApp
+-- | Runs your application using default middlewares (i.e., via 'toWaiApp'). It
+-- reads port information from the PORT environment variable, as used by tools
+-- such as Keter.
+--
+-- Note that the exact behavior of this function may be modified slightly over
+-- time to work correctly with external tools, without a change to the type
+-- signature.
+warpEnv :: (Yesod a, YesodDispatch a a) => a -> IO ()
+warpEnv master = do
+ port <- getEnv "PORT" >>= readIO
+ app <- toWaiApp master
+ run port app
+
-- | Run a development server, where your code changes are automatically
-- reloaded.
develServer :: Int -- ^ port number
View
@@ -1,5 +1,5 @@
name: yesod
-version: 1.1.0.3
+version: 1.1.1
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>

0 comments on commit 8793cff

Please sign in to comment.