packages feed

iterio-server 0.1 → 0.2

raw patch · 5 files changed

+24/−16 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Data.IterIO.Http.Support.RestController: class RestController a
+ Data.IterIO.Http.Support.RestController: class Monad m => RestController m a where restIndex _ = respond404 restShow _ _ = respond404 restNew _ = respond404 restCreate _ = respond404 restEdit _ _ = respond404 restUpdate _ _ = respond404 restDestroy _ _ = respond404
- Data.IterIO.Http.Support.RestController: restCreate :: (RestController a, Monad m) => a -> Action t m ()
+ Data.IterIO.Http.Support.RestController: restCreate :: RestController m a => a -> Action t m ()
- Data.IterIO.Http.Support.RestController: restDestroy :: (RestController a, Monad m) => a -> ByteString -> Action t m ()
+ Data.IterIO.Http.Support.RestController: restDestroy :: RestController m a => a -> ByteString -> Action t m ()
- Data.IterIO.Http.Support.RestController: restEdit :: (RestController a, Monad m) => a -> ByteString -> Action t m ()
+ Data.IterIO.Http.Support.RestController: restEdit :: RestController m a => a -> ByteString -> Action t m ()
- Data.IterIO.Http.Support.RestController: restIndex :: (RestController a, Monad m) => a -> Action t m ()
+ Data.IterIO.Http.Support.RestController: restIndex :: RestController m a => a -> Action t m ()
- Data.IterIO.Http.Support.RestController: restNew :: (RestController a, Monad m) => a -> Action t m ()
+ Data.IterIO.Http.Support.RestController: restNew :: RestController m a => a -> Action t m ()
- Data.IterIO.Http.Support.RestController: restShow :: (RestController a, Monad m) => a -> ByteString -> Action t m ()
+ Data.IterIO.Http.Support.RestController: restShow :: RestController m a => a -> ByteString -> Action t m ()
- Data.IterIO.Http.Support.RestController: restUpdate :: (RestController a, Monad m) => a -> ByteString -> Action t m ()
+ Data.IterIO.Http.Support.RestController: restUpdate :: RestController m a => a -> ByteString -> Action t m ()
- Data.IterIO.Http.Support.RestController: routeRestController :: (Monad m, RestController a) => String -> a -> HttpRoute m t
+ Data.IterIO.Http.Support.RestController: routeRestController :: RestController m a => String -> a -> HttpRoute m t

Files

+ Data/IterIO/Http/Support.hs view
@@ -0,0 +1,10 @@+module Data.IterIO.Http.Support ( module Data.IterIO.Http.Support.Action+                                , module Data.IterIO.Http.Support.Responses+                                , module Data.IterIO.Http.Support.RestController+                                , module Data.IterIO.Http.Support.Routing+                                )where++import Data.IterIO.Http.Support.Action+import Data.IterIO.Http.Support.Responses+import Data.IterIO.Http.Support.RestController+import Data.IterIO.Http.Support.Routing
Data/IterIO/Http/Support/RestController.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings, MultiParamTypeClasses #-} -- | This module defines the 'RestController' class   module Data.IterIO.Http.Support.RestController (@@ -15,29 +15,29 @@  -- |The class @RestController@ allows a set of actions to be routed using -- RESTful HTTP verbs.-class RestController a where+class Monad m => RestController m a where   -- |GET \/-  restIndex :: Monad m => a -> Action t m ()+  restIndex :: a -> Action t m ()   restIndex _ = respond404    -- |GET \/:id   --   -- @id@ is passed in as the second parameter.-  restShow :: Monad m => a -> L.ByteString -> Action t m ()+  restShow :: a -> L.ByteString -> Action t m ()   restShow _ _ = respond404    -- |GET \/new-  restNew :: Monad m => a -> Action t m ()+  restNew :: a -> Action t m ()   restNew _ = respond404    -- |POST \/-  restCreate :: Monad m => a -> Action t m ()+  restCreate :: a -> Action t m ()   restCreate _ = respond404    -- |GET \/:id\/edit   --   -- @id@ is passed in as the second parameter.-  restEdit :: Monad m => a -> L.ByteString -> Action t m ()+  restEdit :: a -> L.ByteString -> Action t m ()   restEdit _ _ = respond404    -- |PUT \/:id@@ -47,7 +47,7 @@   -- Since @PUT@ is not supported by many browsers, this action also responds to   -- requests containing the HTTP header "X-HTTP-Method-Override: PUT"   -- regardless of the actual HTTP method (@GET@ or @POST@)-  restUpdate :: Monad m => a -> L.ByteString -> Action t m ()+  restUpdate :: a -> L.ByteString -> Action t m ()   restUpdate _ _ = respond404    -- |DELETE \/:id@@ -57,7 +57,7 @@   -- Since @DELETE@ is not supported by many browsers, this action also responds to   -- requests containing the HTTP header "X-HTTP-Method-Override: DELETE"   -- regardless of the actual HTTP method (@GET@ or @POST@)-  restDestroy :: Monad m => a -> L.ByteString -> Action t m ()+  restDestroy :: a -> L.ByteString -> Action t m ()   restDestroy _ _ = respond404  -- |Runs an action, passing in named parameter.@@ -89,7 +89,7 @@ -- --    * PUT \/posts\/:id => myRestController#restUpdate ---routeRestController :: (Monad m, RestController a) => String -> a -> HttpRoute m t+routeRestController :: RestController m a => String -> a -> HttpRoute m t routeRestController prefix controller = routeName prefix $ mconcat [     routeTop $ routeMethod "GET" $ routeAction $ restIndex controller   , routeTop $ routeMethod "POST" $ routeAction $ restCreate controller
Data/IterIO/Server/TCPServer.hs view
@@ -89,10 +89,7 @@                  -> HttpRequestHandler IO ()                  -> TCPServer L.ByteString IO simpleHttpServer port reqHandler = minimalTCPServer { serverPort = port, serverHandler = httpAppHandler }-  where httpAppHandler = mkInumM $ do-          req <- httpReqI-          resp <- liftI $ reqHandler req-          irun $ enumHttpResp resp Nothing+  where httpAppHandler = inumHttpServer $ ioHttpServer reqHandler  -- |Creates a 'TCPServer' that echoes each line from the client until EOF. echoServer :: Net.PortNumber -> TCPServer String IO
Examples/BasicSite.hs view
@@ -47,7 +47,7 @@  indexAction :: Action t IO () indexAction = do-  idx <- liftIO $ getStdRandom (randomR (0,length quotes - 1)) +  idx <- lift $ getStdRandom (randomR (0,length quotes - 1))    let quote = quotes !! idx   render "text/html" $ renderHtml $ docTypeHtml $ do     body $ do
iterio-server.cabal view
@@ -1,5 +1,5 @@ Name:           iterio-server-Version:        0.1+Version:        0.2 build-type:     Simple License:        BSD3 License-File:   LICENSE@@ -35,6 +35,7 @@   ghc-options: -Wall    Exposed-modules:+    Data.IterIO.Http.Support     Data.IterIO.Http.Support.Action     Data.IterIO.Http.Support.Responses     Data.IterIO.Http.Support.RestController