packages feed

happstack-server 6.2.5 → 6.3.1

raw patch · 3 files changed

+62/−15 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Happstack.Server.SimpleHTTP: waitForTermination :: IO ()
- Happstack.Server.Routing: method :: (MatchMethod method, Monad m) => method -> WebT m a -> ServerPartT m a
+ Happstack.Server.Routing: method :: (ServerMonad m, MonadPlus m, MatchMethod method) => method -> m ()

Files

happstack-server.cabal view
@@ -1,5 +1,5 @@ Name:                happstack-server-Version:             6.2.5+Version:             6.3.1 Synopsis:            Web related tools and services. Description:         Happstack Server provides an HTTP server and a rich set of functions for routing requests, handling query parameters, generating responses, working with cookies, serving files, and more. For in-depth documentation see the Happstack Crash Course <http://happstack.com/docs/crashcourse/index.html> License:             BSD3
src/Happstack/Server/Routing.hs view
@@ -35,10 +35,10 @@ -- -- Examples -- --- > methodM GET                  -- match GET--- > methodM [HEAD, GET]          -- match HEAD or GET--- > methodM (not . (==) DELETE)  -- match any method except DELETE--- > methodM ()                   -- match any method+-- > method GET                  -- match GET+-- > method [HEAD, GET]          -- match HEAD or GET+-- > method (not . (==) DELETE)  -- match any method except DELETE+-- > method ()                   -- match any method class MatchMethod m where matchMethod :: m -> Method -> Bool instance MatchMethod Method where matchMethod m = (== m) instance MatchMethod [Method] where matchMethod methods = (`elem` methods)@@ -78,8 +78,20 @@     rq <- askRq     unless (f rq) mzero +-- | Guard against the method only (as opposed to 'methodM').+--+-- Example:+--+-- > handler :: ServerPart Response+-- > handler =+-- >     do methodOnly [GET, HEAD]+-- >        ...+method :: (ServerMonad m, MonadPlus m, MatchMethod method) => method -> m ()+method meth = guardRq $ \rq -> matchMethod meth (rqMethod rq)++ -- | Guard against the method. This function also guards against--- *any remaining path segments*. See 'methodOnly' for the version+-- *any remaining path segments*. See 'method' for the version -- that guards only by method. -- -- Example:@@ -88,6 +100,13 @@ -- > handler = -- >     do methodM [GET, HEAD] -- >        ...+-- +-- NOTE: This function is largely retained for backwards+-- compatibility. The fact that implicitly calls 'nullDir' is often+-- forgotten and leads to confusion. It is probably better to just use+-- 'method' and call 'nullDir' explicitly.+-- +-- This function will likely be deprecated in the future. methodM :: (ServerMonad m, MonadPlus m, MatchMethod method) => method -> m () methodM meth = methodOnly meth >> nullDir @@ -100,7 +119,8 @@ -- >     do methodOnly [GET, HEAD] -- >        ... methodOnly :: (ServerMonad m, MonadPlus m, MatchMethod method) => method -> m ()-methodOnly meth = guardRq $ \rq -> matchMethod meth (rqMethod rq)+methodOnly = method+{-# DEPRECATED methodOnly "this function is just an alias for method now" #-}  -- | Guard against the method. Note, this function also guards against -- any remaining path segments. Similar to 'methodM' but with a different type signature.@@ -109,16 +129,11 @@ -- -- > handler :: ServerPart Response -- > handler = methodSP [GET, HEAD] $ subHandler+-- +-- NOTE: This style of combinator is going to be deprecated in the+-- future. It is better to just use 'method'. methodSP :: (ServerMonad m, MonadPlus m, MatchMethod method) => method -> m b-> m b methodSP m handle = methodM m >> handle---- | Guard against the method. Note, this function also guards against any--- remaining path segments.------ DEPRECATED:  Use 'methodSP', 'methodM', or 'methodOnly'-method :: (MatchMethod method, Monad m) => method -> WebT m a -> ServerPartT m a-method m handle = methodSP m (anyRequest handle)-{-# DEPRECATED method "you should be able to use methodSP" #-}  -- | guard which only succeeds if there are no remaining path segments --
src/Happstack/Server/SimpleHTTP.hs view
@@ -44,6 +44,7 @@     , bindPort     , bindIPv4     , parseConfig+    , waitForTermination     -- * Re-exported modules     -- ** Basic ServerMonad functionality     , module Happstack.Server.Monads@@ -94,6 +95,12 @@                                                  , ArgOrder(Permute)                                                  , getOpt                                                  )+#ifdef UNIX+import Control.Concurrent.MVar+import System.Posix.Signals hiding (Handler)+import System.Posix.IO ( stdInput )+import System.Posix.Terminal ( queryTerminal )+#endif  -- | An array of 'OptDescr', useful for processing command line -- options into an 'Conf' for 'simpleHTTP'.@@ -172,6 +179,7 @@ bindPort conf = Listen.listenOn (port conf)  -- | Bind to ip and port and return the socket for use with 'simpleHTTPWithSocket'.+-- -- > -- > import Happstack.Server -- >@@ -181,6 +189,7 @@ -- >           simpleHTTPWithSocket s conf $ ok $ toResponse $  -- >             "now listening on ip addr " ++ addr ++  -- >             " and port " ++ show (port conf)+-- bindIPv4 :: String  -- ^ IP address to bind to (must be an IP address and not a host name)          -> Int     -- ^ port number to bind to          -> IO Socket@@ -205,3 +214,26 @@     ++ "It is just not here</p>"     ++ "</body></html>"     where ver = DV.showVersion Cabal.version+++-- | Wait for a signal.+--   On unix, a signal is sigINT or sigTERM (aka Control-C).+--  +-- On windows, the signal is entering: e <return>+waitForTermination :: IO ()+waitForTermination+    = do+#ifdef UNIX+         istty <- queryTerminal stdInput+         mv <- newEmptyMVar+         installHandler softwareTermination (CatchOnce (putMVar mv ())) Nothing+         case istty of+           True  -> do installHandler keyboardSignal (CatchOnce (putMVar mv ())) Nothing+                       return ()+           False -> return ()+         takeMVar mv+#else+         let loop 'e' = return () +             loop _   = getChar >>= loop+         loop 'c'+#endif