Safe Haskell | None |
---|
The Play Framework style data binding in Scotty.
Data difinition:
{-# LANGUAGE TemplateHaskell #-} import Web.Scotty.Binding.Play (deriveBindable) data Sample = Sample { field1 :: Int , field2 :: Text } deriveBindable ''Sample
set as GET parameter:
> curl http://localhost:3000/?data.field1=1&data.field2=whisky
We can get Sample
in Scotty:
main :: IO () main = scotty 3000 $ get "/" $ do a <- parseParam "data" liftIO $ print $ field1 a --> 1 liftIO $ print $ field2 a --> "whisky"
- class Bindable a where
- parseParams :: Text -> ActionM a
- parseParams' :: Text -> Maybe Text -> ActionM a
- deriveBindable :: Name -> DecsQ