scotty-binding-play 1.0 → 1.1
raw patch · 3 files changed
+29/−1 lines, 3 files
Files
- Web/Scotty/Binding/Play.hs +5/−0
- scotty-binding-play.cabal +1/−1
- test/Spec.hs +23/−0
Web/Scotty/Binding/Play.hs view
@@ -32,6 +32,7 @@ , deriveBindable ) where +import Control.Applicative import Control.Monad.Error.Class (catchError) import Data.ByteString (ByteString) import Data.Maybe (catMaybes)@@ -87,6 +88,10 @@ instance Bindable Text where parseParams' = parse++instance Bindable a => Bindable (Maybe a) where+ parseParams' pre msuf = (Just <$> parseParams' pre msuf)+ `catchError` \_ -> return Nothing parse :: Parsable a => Text -> Maybe Text -> ActionM a parse prefix msuffix = param $ mconcat $ catMaybes [Just prefix, msuffix]
scotty-binding-play.cabal view
@@ -1,5 +1,5 @@ name: scotty-binding-play-version: 1.0+version: 1.1 synopsis: The Play Framework style data binding in Scotty. description: The Play Framework style data binding in Scotty. license: BSD3
test/Spec.hs view
@@ -78,6 +78,14 @@ deriveBindable ''Test3 +data Test4 = Test4+ { field41 :: Maybe Int+ , field42 :: Maybe Test1+ }+ deriving (Show, Eq)++deriveBindable ''Test4+ main :: IO () main = hspec $ do describe "Web.Scotty.Binding.Play" $ do@@ -108,3 +116,18 @@ ] it "bind nested data GET" $ test GET ex4 ac4 it "bind nested data POST" $ test POST ex4 ac4+ let ex5 = Just 1 :: Maybe Int+ let ac5 = [ ("data", "1") ]+ it "bind Maybe data GET" $ test GET ex5 ac5+ it "bind Maybe data POST" $ test POST ex5 ac5+ let ex6 = Nothing :: Maybe Int+ let ac6 = []+ it "bind Maybe data GET" $ test GET ex6 ac6+ it "bind Maybe data POST" $ test POST ex6 ac6+ let ex7 = Test4 Nothing (Just ex1)+ let ac7 =+ [ ("data.field42.field1", "1")+ , ("data.field42.field2", "test")+ ]+ it "bind Maybe struct data GET" $ test GET ex7 ac7+ it "bind Maybe struct data POST" $ test POST ex7 ac7