packages feed

ivy-web 0.1.1 → 0.2

raw patch · 3 files changed

+28/−23 lines, 3 filesdep +snapdep +snap-coredep −http-typesdep −waiPVP ok

version bump matches the API change (PVP)

Dependencies added: snap, snap-core

Dependencies removed: http-types, wai

API changes (from Hackage documentation)

- Web.Ivy.Types: type Application = Request -> Iteratee ByteString IO Response
- Web.Ivy.Routes: Route :: a -> Route
+ Web.Ivy.Routes: Route :: a -> Route m
- Web.Ivy.Routes: data Route
+ Web.Ivy.Routes: data Route m
- Web.Ivy.Routes: routeIso :: (Typeable a, Handler a) => Iso a Route
+ Web.Ivy.Routes: routeIso :: (Typeable a, Handler m a) => Iso a (Route m)
- Web.Ivy.Routes: url :: (Typeable a, Handler a) => Printer Route -> a -> Maybe String
+ Web.Ivy.Routes: url :: (Typeable a, Handler m a) => Printer (Route m) -> a -> Maybe String
- Web.Ivy.Types: class Handler a
+ Web.Ivy.Types: class MonadSnap m => Handler m a
- Web.Ivy.Types: get, handle, delete, put, post :: Handler a => a -> Application
+ Web.Ivy.Types: get, handle, delete, put, post :: Handler m a => a -> m ()

Files

ivy-web.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.1.1+Version:             0.2  -- A short (one-line) description of the package. Synopsis:            A lightweight web framework@@ -25,7 +25,9 @@     .         *   Easy i18n     .-        For an example, please refer to <https://github.com/lilac/ivy-example/>+        For an example, please refer to <https://github.com/lilac/ivy-demo/>+    .+        Note: Unlike 0.1 version, this version support snap-server as backend.  -- URL for the project homepage or repository. Homepage:            https://github.com/lilac/ivy-web/@@ -70,8 +72,10 @@     base >= 3 && < 5,     partial-isomorphisms < 0.3,     invertible-syntax >= 0.2,-    wai >= 0.4.0,-    http-types >= 0.6.5+    --wai >= 0.4.0,+    --http-types >= 0.6.5+    snap >= 0.5,+    snap-core >= 0.5       -- Modules not exported by this package.
src/Web/Ivy/Routes.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell, NoMonomorphismRestriction, RankNTypes, GADTs, ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell, NoMonomorphismRestriction, RankNTypes, GADTs, ScopedTypeVariables, MultiParamTypeClasses #-} module Web.Ivy.Routes where  import Prelude hiding (print)@@ -17,11 +17,12 @@     syntax :: Syntax s => a -> s a -} -data Route = forall a. (Typeable a, Handler a) => Route a+data Route m where+    Route :: forall m a. (Typeable a, Handler m a) => a -> Route m -routeIso :: forall a. (Typeable a, Handler a) => Iso a Route+routeIso :: forall m a. (Typeable a, Handler m a) => Iso a (Route m) routeIso = Iso f g where-    f = Just . Route+    f x = Just (Route x )     g r = case r of Route r' -> cast r'  {-@@ -40,7 +41,7 @@  parseUrl = parse -url :: (Typeable a, Handler a) => Printer Route -> a -> Maybe String+url :: (Typeable a, Handler m a) => Printer (Route m) -> a -> Maybe String url r h = print r (Route h)  dash = text "-"
src/Web/Ivy/Types.hs view
@@ -1,24 +1,24 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, MultiParamTypeClasses #-} module Web.Ivy.Types      (Handler(..)-    , Application)+     )     where-import Network.Wai-import Network.HTTP.Types+import Snap.Types -class Handler a where-    get, post, put, delete, handle :: a -> Application+class MonadSnap m => Handler m a where+    get, post, put, delete, handle :: a -> m ()     get _ = unimplemented     post _ = unimplemented     put _ = unimplemented     delete _ = unimplemented -    handle a req = case requestMethod req of-        m | m == methodGet -> get a req-          | m == methodPost -> post a req-          | m == methodPut -> put a req-          | m == methodDelete -> delete a req-        otherwise -> unimplemented req+    handle a = getRequest >>= \req -> case rqMethod req of+        m | m == GET -> get a+          | m == POST -> post a+          | m == PUT -> put a+          | m == DELETE -> delete a+        otherwise -> unimplemented -unimplemented :: Application-unimplemented _ = return $ responseLBS status501 [("Content-Type", "text/plain")] "not implemented method"+unimplemented :: MonadSnap m => m ()+unimplemented = writeBS "not implemented method"+