packages feed

web-fpco (empty) → 0.1.0.0

raw patch · 5 files changed

+92/−0 lines, 5 filesdep +basedep +happstack-serverdep +safesetup-changed

Dependencies added: base, happstack-server, safe, snap-core, snap-server

Files

+ Happstack/Server/Env.hs view
@@ -0,0 +1,24 @@+module Happstack.Server.Env+    ( simpleHTTP+    , module Happstack.Server+    ) where++import           Happstack.Server   hiding (simpleHTTP)+import qualified Happstack.Server   as Happstack+import           Safe               (readMay)+import           System.Environment (getEnvironment)++-- | An alternate @simpleHTTP@ which reads the port to listen to from the PORT+-- environment variable. This configuration approach is used by the FP Complete+-- School of Haskell and the Keter deployment manager.+simpleHTTP :: ToMessage a => Conf -> ServerPartT IO a -> IO ()+simpleHTTP conf serverpart = do+    env <- getEnvironment+    case lookup "PORT" env of+        Nothing -> error "PORT environment variable not found"+        Just portS ->+            case readMay portS of+                Nothing -> error $ "Invalid PORT enviornment variable: " ++ portS+                Just port' -> Happstack.simpleHTTP conf+                    { port = port'+                    } serverpart
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2013 FP Complete, http://www.fpcomplete.com/++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Snap/Http/Server/Env.hs view
@@ -0,0 +1,23 @@+module Snap.Http.Server.Env+    ( httpServe+    , module Snap.Http.Server+    ) where++import           Safe               (readMay)+import           Snap.Core          (Snap)+import           Snap.Http.Server   hiding (httpServe)+import qualified Snap.Http.Server   as Snap+import           System.Environment (getEnvironment)++-- | An alternate @httpServe@ which reads the port to listen to from the PORT+-- environment variable. This configuration approach is used by the FP Complete+-- School of Haskell and the Keter deployment manager.+httpServe :: Config Snap a -> Snap () -> IO ()+httpServe config snap = do+    env <- getEnvironment+    case lookup "PORT" env of+        Nothing -> error "PORT environment variable not found"+        Just portS ->+            case readMay portS of+                Nothing -> error $ "Invalid PORT enviornment variable: " ++ portS+                Just port -> Snap.httpServe (setPort port config) snap
+ web-fpco.cabal view
@@ -0,0 +1,23 @@+name:                web-fpco+version:             0.1.0.0+synopsis:            Wrappers for web frameworks to ease usage with the FP Complete environment.+description:         This package provides very simplistic wrappers to enable running code using the Snap and Happstack web frameworks on the FP Complete environment. The only modification to standard behavior is that the port number is read from the PORT environment variable as opposed to being specified on either the command line or in the code itself. If you're using Yesod, the function warpEnv is provided in the Yesod module itself, which performs the same function.+                  .+                     For the most part, it should be sufficient to import the relevant module from this package in place of the standard module, e.g. import @Snap.Http.Server.Env@ instead of @Snap.Http.Server@, or @Happstack.Server.Env@ instead of @Happstack.Server@.+homepage:            https://github.com/fpco/web-fpco+license:             MIT+license-file:        LICENSE+author:              Michael Snoyman+maintainer:          michael@fpcomplete.com+category:            Web+build-type:          Simple+cabal-version:       >=1.8++library+  exposed-modules:     Snap.Http.Server.Env+                       Happstack.Server.Env+  build-depends:       base >= 4 && < 5+                     , safe >= 0.3+                     , snap-core >= 0.9+                     , snap-server >= 0.9+                     , happstack-server >= 7.1