Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (34 sloc) 1.23 KB
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE DataKinds #-}
import Web.Apiary
import Web.Apiary.PureScript
import Network.Wai.Handler.Warp
import Language.Haskell.TH
import System.Directory
import System.FilePath
-- please run
-- $ bower install philopon/purescript-xhr
-- in examples directory.
main :: IO ()
main = do
setCurrentDirectory $(location >>= stringE . takeDirectory . loc_filename)
runApiaryWith (run 3000) (initPureScript def { development = True }) def $ do
method GET $ do
root . action $ do
contentType "text/html"
file "pureScript.html" Nothing
[capture|/test.js|] . action $
pureScript "pureScript.purs"
[capture|/api/i::Int|] .
([key|test|] ?? "b(default: 0)" =?: pInt) .
document "a + b" . action $ do
(i, mbj) <- [params|i, test|]
let j = maybe 0 id mbj
contentType "application/json"
bytes "{ \"test\": "
appendShowing (i + j)
appendChar '}'
[capture|/api/documentation|] . method GET . action $
defaultDocumentationAction def
Jump to Line
Something went wrong with that request. Please try again.