servant/example/greet.hs
2014-11-25 01:36:34 +01:00

25 lines
No EOL
629 B
Haskell

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
import Data.Proxy
import Servant
import Servant.JQuery
data Greet = Greet
type TestApi =
"hello" :> Capture "name" String :> QueryParam "capital" Bool :> QueryParam "q" String :> Get Greet
:<|> "greet" :> ReqBody Greet :> Post Greet
:<|> "delete" :> Capture "greetid" String :> "haha" :> Delete
testApi :: Proxy TestApi
testApi = Proxy
getHello :<|> postGreet :<|> deleteGreet = jquery testApi
main :: IO ()
main =
mapM_ printJS [ getHello "getHello"
, postGreet "postGreet"
, deleteGreet "deleteGreet"
]