@@ -19,9 +19,6 @@ newtype Counter = Counter { value :: Int }
20instance ToJSON Counter
20instance ToJSON Counter
22−instance ToSample Counter where
25-- * Shared counter operations
22-- * Shared counter operations
27-- Creating a counter that starts from 0
24-- Creating a counter that starts from 0
@@ -42,7 +39,6 @@ currentValue counter = liftIO $ readTVarIO counter
42-- * Our API type
39-- * Our API type
43type TestApi = "counter" :> Post Counter -- endpoint for increasing the counter
40type TestApi = "counter" :> Post Counter -- endpoint for increasing the counter
44 :<|> "counter" :> Get Counter -- endpoint to get the current value
41 :<|> "counter" :> Get Counter -- endpoint to get the current value
45− :<|> "doc" :> Raw -- serve the documentation
46 :<|> Raw -- used for serving static files
42 :<|> Raw -- used for serving static files
48testApi :: Proxy TestApi
44testApi :: Proxy TestApi
@@ -58,7 +54,6 @@ www = "examples/www"
58server :: TVar Counter -> Server TestApi
54server :: TVar Counter -> Server TestApi
59server counter = counterPlusOne counter -- (+1) on the TVar
55server counter = counterPlusOne counter -- (+1) on the TVar
60 :<|> currentValue counter -- read the TVar
56 :<|> currentValue counter -- read the TVar
61− :<|> serveDocumentation testApi -- serve the API docs
62 :<|> serveDirectory www -- serve static files
57 :<|> serveDirectory www -- serve static files
64runServer :: TVar Counter -- ^ shared variable for the counter
59runServer :: TVar Counter -- ^ shared variable for the counter
@@ -70,7 +65,7 @@ runServer var port = run port (serve testApi $ server var)
70incCounterNamed :: FunctionName -> AjaxReq
65incCounterNamed :: FunctionName -> AjaxReq
71currentValueNamed :: FunctionName -> AjaxReq
66currentValueNamed :: FunctionName -> AjaxReq
73−incCounterNamed :<|> currentValueNamed :<|> _ :<|> _ = jquery testApi
68+incCounterNamed :<|> currentValueNamed :<|> _ = jquery testApi
75writeJS :: FilePath -> [AjaxReq] -> IO ()
70writeJS :: FilePath -> [AjaxReq] -> IO ()
76writeJS fp functions = writeFile fp $
71writeJS fp functions = writeFile fp $