packages feed

gingersnap 0.2.2.1 → 0.2.2.2

raw patch · 2 files changed

+9/−9 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

README.md view
@@ -6,7 +6,7 @@  As it's just a set of idioms, it's easy to only use 'em where you need 'em. An app could have only a single endpoint that uses Gingersnap, with the rest-using plain `snap-core`.+using plain `snap` or `snap-core`.  How do we use it? This README is also a Literate Haskell file so it's a full example you can run with markdown-unlit. Let's get started:@@ -35,14 +35,14 @@ define a little bit of setup code later on in the file.  ```haskell-data SomeData = SomeData Int Bool+data Character = Character { name :: String, age :: Int }  deriving (Show, Generic) -instance ToJSON SomeData+instance ToJSON Character  one :: Ctx -> Snap () one ctx =-   pureRsp ctx $ rspGood $ SomeData 5 True+   pureRsp ctx $ rspGood $ Character { name = "Yoda", age = 900 } ```  You can run the code from this file with@@ -57,7 +57,7 @@  You should get back: -    {"result":[5,true]}+    {"result":{"age":900,"name":"Yoda"}}  A few things to notice:   - The endpoint takes as an argument a "Ctx". We'll see the definition of that@@ -137,12 +137,12 @@ two :: Ctx -> Snap () two ctx = do    inTransaction ctx $ \conn -> do-      [Only x] <- query_ conn " SELECT 2 + 2 "-      pure $ rspGood $ SomeData x True+      [Only x] <- query_ conn " SELECT 3 + 3 "+      pure $ rspGood $ Character { name = "Calvin", age = x } ```      $ curl 'localhost:8000/two'-    {"result":[4,true]}+    {"result":{"age":6,"name":"Calvin"}} ~ $  Nice! This uses "inTransaction", another core tool in Gingersnap: 
gingersnap.cabal view
@@ -1,5 +1,5 @@ name:                gingersnap-version:             0.2.2.1+version:             0.2.2.2 synopsis:   Tools for consistent and safe JSON APIs with snap-core and postgresql-simple description: