remote-json-server (empty) → 0.2
raw patch · 5 files changed
+108/−0 lines, 5 filesdep +aesondep +basedep +data-default-classsetup-changed
Dependencies added: aeson, base, data-default-class, natural-transformation, remote-json, scotty, text, transformers, warp
Files
- Control/Remote/Monad/JSON/Server.hs +41/−0
- LICENSE +28/−0
- README.md +2/−0
- Setup.hs +2/−0
- remote-json-server.cabal +35/−0
+ Control/Remote/Monad/JSON/Server.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE GADTs #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeOperators #-}++module Control.Remote.Monad.JSON.Server+ ( -- * Ways of building the actionable parts of a Scotty server+ scottyReceiveAPI+ , serverReceiveAPI+ ) where++import Control.Remote.Monad.JSON.Router (ReceiveAPI(..))+import Control.Monad.IO.Class+import Control.Natural+import Data.Aeson()+import Data.Default.Class (def)+import Web.Scotty (scottyOpts)+import Web.Scotty.Trans as T+import Network.Wai.Handler.Warp (setPort)+++-- | A way of building client 'SendAPI' support, using wreq.+{-+ serverReceiveAPI :: forall e (m :: * -> *) (t :: * -> *) a.+ (Foldable t, ToJSON a, MonadIO m, ScottyError e) =>+ (ReceiveAPI (Maybe Value) -> IO (t a)) -> ActionT e m ()+-}+-- | Blocking function that listens on a specific port, to a specific path.+serverReceiveAPI :: Int -> String -> (ReceiveAPI :~> IO) -> IO ()+serverReceiveAPI port path f = scottyOpts opts $ post (literal path) $ scottyReceiveAPI f+ where opts = def { verbose = 0, settings = setPort port (settings def) }++-- | Build the 'ActionT' action for Scotty.+scottyReceiveAPI :: (ScottyError e, MonadIO m)+ => (ReceiveAPI :~> IO) -> ActionT e m ()+scottyReceiveAPI (Nat f) = do+ d <- jsonData+ r <- liftIO $ f $ Receive $ d+ case r of+ Nothing -> return ()+ Just v -> T.json v
+ LICENSE view
@@ -0,0 +1,28 @@+Copyright (c) 2015, Functional Programming at the University of Kansas+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++* Redistributions of source code must retain the above copyright notice, this+ list of conditions and the following disclaimer.++* Redistributions in binary form must reproduce the above copyright notice,+ this list of conditions and the following disclaimer in the documentation+ and/or other materials provided with the distribution.++* Neither the name of remote-json nor the names of its+ contributors may be used to endorse or promote products derived from+ this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+
+ README.md view
@@ -0,0 +1,2 @@+A sub-package of remote-json that provides the ReceiveAPI capabilities.+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ remote-json-server.cabal view
@@ -0,0 +1,35 @@+name: remote-json-server+version: 0.2+synopsis: Web server wrapper for remote-json+description: Web server, using scotty, for the JSON RPC protocol.+license: BSD3+license-file: LICENSE+author: Justin Dawson and Andy Gill+maintainer: JDawson@ku.edu+copyright: (c) 2016 The University of Kansas+category: Network+build-type: Simple+extra-source-files: README.md+tested-with: GHC == 7.10.3+cabal-version: >=1.10++source-repository head+ type: git+ location: git://github.com/ku-fpg/remote-json++library+ exposed-modules: Control.Remote.Monad.JSON.Server++ -- other-modules:+ build-depends: aeson >= 0.8 && < 0.12+ , base >= 4 && < 5+ , data-default-class == 0.0.1+ , natural-transformation >= 0.3.1 && < 0.4+ , remote-json >= 0.2 && < 0.3+ , warp >= 3.2 && < 3.3+ , scotty >= 0.10+ , text >= 1.2 && < 1.3+ , transformers >= 0.4 && < 0.6+ hs-source-dirs: .+ default-language: Haskell2010+ ghc-options: -Wall