packages feed

digestive-functors-scotty 0.2.0.0 → 0.2.0.1

raw patch · 2 files changed

+39/−3 lines, 2 filesdep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: text

API changes (from Hackage documentation)

Files

digestive-functors-scotty.cabal view
@@ -1,5 +1,5 @@ name:                digestive-functors-scotty-version:             0.2.0.0+version:             0.2.0.1 synopsis:            Scotty backend for the digestive-functors library description:         Scotty backend for the digestive-functors library homepage:            https://bitbucket.org/wniare/digestive-functors-scotty@@ -22,7 +22,7 @@                      , scotty             ==0.7.*                      , bytestring         >=0.9   && <0.11                      , http-types         ==0.8.*-                     , text               >=0.11  && <1.0+                     , text               >=0.11  && <1.2                      , wai                >=2.0.0 && <2.2                      , wai-extra          >=2.0.1 && <2.2 
src/Text/Digestive/Scotty.hs view
@@ -1,4 +1,40 @@--- | Module providing a scotty backend for the digestive-functors library+{-|+Module providing the scotty backend for the digestive-functors library++>{-# LANGUAGE OverloadedStrings #-}+>+>import Web.Scotty+>+>import Text.Digestive+>import Text.Digestive.Scotty+>+>import Control.Applicative ((<$>), (<*>))+>+>data FormData = FormData { field1 :: String+>                         , field2 :: Integer+>                         }+>+>testForm :: Monad m => Form String m FormData+>testForm = FormData+>           <$> "field1" .: string Nothing+>           <*> "field2" .: stringRead "read failed" Nothing+>+>main :: IO ()+>main = scotty 3000 $ do+>    get "/" $ do+>        setHeader "Content-Type" "text/html"+>        raw " <html><body><form enctype='multipart/form-data' method='post'> \+>              \ <input type='text' name='test-form.field1'/> \+>              \ <input type='text' name='test-form.field2'/> \+>              \ <input type='submit'/> \+>              \ </form></body></html>"+>+>    post "/" $ do+>        (view, result) <- runForm "test-form" testForm+>        case result of+>            Just d -> ... Success! `d` contains constructed FormData.+>            _ -> ... Failure! Use `view` variable to access error messages.+-} module Text.Digestive.Scotty     ( runForm     ) where