packages feed

hack-handler-happstack 2009.6.5 → 2009.6.24

raw patch · 5 files changed

+74/−16 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ Nemesis view
@@ -0,0 +1,36 @@+nemesis = do+  +  clean+    [ "**/*.hi"+    , "**/*.o"+    , "manifest"+    , "main"+    , "nemesis-tmp.*"+    , "Test"+    ]+  ++  desc "prepare cabal dist"+  task "dist" $ do+    sh "cabal clean"+    sh "cabal configure"+    sh "cabal sdist"+++  desc "put all .hs files in manifest"+  task "manifest" $ do+    sh "find . | grep 'hs$' > manifest"+++  desc "start console"+  task "i" (sh "ghci -isrc src/Hack/Handler/Happstack.hs")++  desc "test"+  task "test" $ do+    sh "ghc --make -isrc src/Test.hs -o Test"+    sh "echo ready..."+    sh "./Test"+  +  desc "show sloc"+  task "stat" $ do+    sh "cloc -match-f=hs$ --quiet src"
changelog.md view
@@ -1,3 +1,10 @@+2009.6.24+---------++### Fix++* escaped scriptName and pathInfo+ 2009.6.5 -------- 
hack-handler-happstack.cabal view
@@ -1,5 +1,5 @@ Name:                 hack-handler-happstack-Version:              2009.6.5+Version:              2009.6.24 Build-type:           Simple Synopsis:             Hack Happstack server handler Description:          Hack Happstack server handler@@ -11,7 +11,7 @@ Cabal-version:        >= 1.2 category:             Web homepage:             http://github.com/nfjinjing/hack/tree/master-data-files:           readme.md, changelog.md+data-files:           readme.md, changelog.md, Nemesis, src/Test.hs  library   ghc-options: -Wall
src/Hack/Handler/Happstack.hs view
@@ -5,22 +5,23 @@  module Hack.Handler.Happstack (run, runWithConfig, ServerConf(..)) where -import qualified Hack as Hack-import Hack hiding (serverName)-import Happstack.Server.SimpleHTTP as Happstack hiding (port)-import qualified Happstack.Server.SimpleHTTP as H  import Control.Arrow ((>>>))+import Control.Monad.State+import Data.Char import Data.Default+import Data.Default import Data.List-import Data.Char import Data.Maybe-import Control.Monad.State-import Data.Default--import qualified Data.Map as M+import Hack hiding (serverName)+import Happstack.Server.SimpleHTTP as Happstack hiding (port, escape)+import Network.URI (escapeURIString, isAllowedInURI) import qualified Data.ByteString.Char8 as S+import qualified Data.Map as M+import qualified Hack as Hack+import qualified Happstack.Server.SimpleHTTP as H + -- | we need this for 1. port 2. a bug in current Happstack. --   i.e. rqPeer will not give the corrent value for serverName and port data ServerConf = ServerConf { port :: Int, serverName :: String }@@ -45,8 +46,8 @@     reqToEnv conf' req =       def { requestMethod = convertRequestMethod $ rqMethod req           , scriptName    = ""-          , pathInfo      = "/" ++ (intercalate "/" $ rqPaths req)-          , queryString   = remove_question_mark $ rqQuery req+          , pathInfo      = escape $ "/" ++ (intercalate "/" $ rqPaths req)+          , queryString   = escape $ remove_question_mark $ rqQuery req           , Hack.serverName    = serverName conf' -- (fst $ rqPeer req) is supposed to work, but does not           , serverPort    = port conf'           , http           = toHttp (rqHeaders req)@@ -54,6 +55,7 @@           }     remove_question_mark = dropWhile (== '?')     +    escape = escapeURIString isAllowedInURI          convertRequestMethod Happstack.OPTIONS     =     Hack.OPTIONS     convertRequestMethod Happstack.GET         =     Hack.GET@@ -63,9 +65,8 @@     convertRequestMethod Happstack.DELETE      =     Hack.DELETE     convertRequestMethod Happstack.TRACE       =     Hack.TRACE     convertRequestMethod Happstack.CONNECT     =     Hack.CONNECT-          -          -          +    + toHttp :: Headers -> [(String, String)] toHttp = M.toList >>> map snd >>> map headerToPair 
+ src/Test.hs view
@@ -0,0 +1,14 @@+module Main where++import Hack+import Hack.Handler.Happstack+import Hack.Contrib.Middleware.Inspect+import Hack.Contrib.Middleware.Debug+import Hack.Contrib.Utils+import Data.ByteString.Lazy.Char8 (pack)++app :: Application+app = \env -> return $+  Response 200 [ ("Content-Type", "text/plain") ] (pack "Hello World")++main = run $ use [debug (\e r -> print e), inspect] app