packages feed

web-routes-happstack 0.22.1 → 0.22.2

raw patch · 2 files changed

+29/−4 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Web/Routes/Happstack.hs view
@@ -27,21 +27,45 @@  instance (Happstack m) => Happstack (RouteT url m) -implSite :: (Functor m, Monad m, MonadPlus m, ServerMonad m) => String -> FilePath -> Site url (m a) -> m a+-- | convert a 'Site' to a normal Happstack route+--+-- calls 'mzero' if the route can be decoded.+--+-- see also: 'implSite_'+implSite :: (Functor m, Monad m, MonadPlus m, ServerMonad m) => +            String         -- ^ "http://example.org"+         -> FilePath       -- ^ path to this handler, .e.g. "/route/"+         -> Site url (m a) -- ^ the 'Site'+         -> m a implSite domain approot siteSpec =   do r <- implSite_ domain approot siteSpec      case r of        (Left _) -> mzero        (Right a) -> return a -implSite_ :: (Functor m, Monad m, MonadPlus m, ServerMonad m) => String -> FilePath -> Site url (m a) -> m (Either String a)+-- | convert a 'Site' to a normal Happstack route+--+-- If url decoding fails, it returns @Left "the parse error"@,+-- otherwise @Right a@.+--+-- see also: 'implSite'+implSite_ :: (Functor m, Monad m, MonadPlus m, ServerMonad m) => +             String          -- ^ "http://example.org"+          -> FilePath        -- ^ path to this handler, .e.g. "/route/"+          -> Site url (m a)  -- ^ the 'Site'+          -> m (Either String a)  implSite_ domain approot siteSpec =     dirs approot $ do rq <- askRq-                      let pathInfo = intercalate "/" (rqPaths rq)+                      let pathInfo = intercalate "/" (map escapeSlash (rqPaths rq))                           f        = runSite (domain ++ approot) siteSpec pathInfo                       case f of                         (Left parseError) -> return (Left parseError)                         (Right sp)   -> Right <$> (localRq (const $ rq { rqPaths = [] }) sp)+        where+          escapeSlash :: String -> String+          escapeSlash [] = []+          escapeSlash ('/':cs) = "%2F" ++ escapeSlash cs+          escapeSlash (c:cs)   = c : escapeSlash cs {-  implSite__ :: (Monad m) => String -> FilePath -> ([ErrorMsg] -> ServerPartT m a) -> Site url (ServerPartT m a) -> (ServerPartT m a) implSite__ domain approot handleError siteSpec =@@ -52,6 +76,7 @@                         (Failure errs) -> handleError errs                         (Success sp)   -> localRq (const $ rq { rqPaths = [] }) sp -}+ -- | similar to 'seeOther' but takes a 'URL' 'm' as an argument seeOtherURL :: (ShowURL m, FilterMonad Response m) => URL m -> m Response seeOtherURL url = 
web-routes-happstack.cabal view
@@ -1,5 +1,5 @@ Name:             web-routes-happstack-Version:          0.22.1+Version:          0.22.2 License:          BSD3 License-File:     LICENSE Author:           jeremy@seereason.com