yaml-rpc-scotty 1.0 → 1.0.2
raw patch · 2 files changed
+19/−5 lines, 2 filesdep +mmorphdep ~aesondep ~yaml-rpc
Dependencies added: mmorph
Dependency ranges changed: aeson, yaml-rpc
Files
- Network/YAML/Scotty.hs +15/−2
- yaml-rpc-scotty.cabal +4/−3
Network/YAML/Scotty.hs view
@@ -1,9 +1,11 @@ {-# LANGUAGE OverloadedStrings #-} -module Network.YAML.Scotty (servePost) where+module Network.YAML.Scotty (servePost, servePostT) where +import Control.Monad.Morph import Control.Monad.IO.Class import Web.Scotty+import qualified Web.Scotty.Trans as Trans import Network.HTTP.Types import qualified Data.Text as T import Data.Aeson hiding (json)@@ -12,7 +14,7 @@ import Network.YAML.TH.Dispatcher -- | Scotty handler. Serves each method on @/:method@.-servePost :: Dispatcher -> ScottyM ()+servePost :: Dispatcher IO -> ScottyM () servePost dispatcher = post "/:method" $ do methodName <- param "method" case dispatcher methodName of@@ -21,4 +23,15 @@ args <- jsonData result <- liftIO $ method args json result++-- | Scotty handler. Serves each method on @/:method@.+servePostT :: (Trans.ScottyError e, MonadIO m) => Dispatcher m -> Trans.ScottyT e m ()+servePostT dispatcher = Trans.post "/:method" $ do+ methodName <- Trans.param "method"+ case dispatcher methodName of+ Nothing -> Trans.status status404+ Just method -> do+ args <- Trans.jsonData+ result <- lift $ method args+ Trans.json result
yaml-rpc-scotty.cabal view
@@ -1,6 +1,6 @@ Name: yaml-rpc-scotty -Version: 1.0+Version: 1.0.2 Synopsis: Scotty server backend for yaml-rpc Description: This package provides Scotty-based server backend for yaml-rpc package.@@ -17,13 +17,14 @@ Exposed-modules: Network.YAML.Scotty Build-depends: base >= 3 && <= 5, transformers >= 0.3.0.0,- aeson >= 0.7.0.3,+ mmorph >= 1.0.3,+ aeson >= 0.7.0.6, yaml, containers, text >= 1.1.1.3, http-types >= 0.8.5, scotty >= 0.8.0,- yaml-rpc >= 1.0+ yaml-rpc >= 1.0.2 Other-modules: Test.Server, Test.TestAPIImpl