git.iko.soy/typeable/servant-reflex
on master help sign in
Fix reversed path parts and add example case to test
2e25bc6Greg Hale
exec/API.hs+1
@@ -14,6 +14,7 @@ type API = "getunit" :> Get '[JSON] ()
14 :> Get '[JSON] String
14 :> Get '[JSON] String
15 :<|> "double" :> ReqBody '[JSON] Double
15 :<|> "double" :> ReqBody '[JSON] Double
16 :> Post '[JSON] Double
16 :> Post '[JSON] Double
17+ :<|> "a" :> "b" :> QueryFlag "gusto" :> Get '[JSON] String
17 :<|> Raw
18 :<|> Raw
18
19
19type GET = Get '[JSON] ()
20type GET = Get '[JSON] ()
exec/Example.hs+8−1
@@ -30,7 +30,7 @@ run = do
30 el "br" (return ())
30 el "br" (return ())
31
31
32 -- Name the computed API client functions
32 -- Name the computed API client functions
33− let (getUnit :<|> getInt :<|> sayhi :<|> dbl :<|> doRaw) =
33+ let (getUnit :<|> getInt :<|> sayhi :<|> dbl :<|> multi :<|> doRaw) =
34 client api (Proxy :: Proxy m) url
34 client api (Proxy :: Proxy m) url
35
35
36 elClass "div" "demo-group" $ do
36 elClass "div" "demo-group" $ do
@@ -80,6 +80,13 @@ run = do
80 el "br" (return ())
80 el "br" (return ())
81 display =<< holdDyn "No number yet" (fmap show $ fmapMaybe reqSuccess dblResp)
81 display =<< holdDyn "No number yet" (fmap show $ fmapMaybe reqSuccess dblResp)
82
82
83+ elClass "div" "demo-group" $ do
84+ text "Multi-part path"
85+ b <- (current . value) <$> checkbox False def
86+ mpGo <- button "Test"
87+ multiResp <- multi b mpGo
88+ dynText =<< holdDyn "No res yet" (fmap show $ fmapMaybe reqSuccess $ multiResp)
89+
83showXhrResponse :: XhrResponse -> String
90showXhrResponse :: XhrResponse -> String
84showXhrResponse (XhrResponse stat stattxt rbmay rtmay) =
91showXhrResponse (XhrResponse stat stattxt rbmay rtmay) =
85 unlines ["stat: " ++ show stat
92 unlines ["stat: " ++ show stat
src/Servant/Common/Req.hs+1−1
@@ -99,7 +99,7 @@ performRequest reqMethod req reqHost trigger = do
99
99
100 -- Ridiculous functor-juggling! How to clean this up?
100 -- Ridiculous functor-juggling! How to clean this up?
101 let t :: Behavior t [Either String String]
101 let t :: Behavior t [Either String String]
102− t = sequence $ reqPathParts req
102+ t = sequence $ L.reverse $ reqPathParts req
103
103
104 baseUrl :: Behavior t (Either String String)
104 baseUrl :: Behavior t (Either String String)
105 baseUrl = Right . showBaseUrl <$> current reqHost
105 baseUrl = Right . showBaseUrl <$> current reqHost
testserver/Main.hs+2−1
@@ -44,7 +44,7 @@ data App = App
44--
44--
45-- Each handler runs in the 'ExceptT ServantErr IO' monad.
45-- Each handler runs in the 'ExceptT ServantErr IO' monad.
46server :: Server API (Handler App App)
46server :: Server API (Handler App App)
47−server = return () :<|> return 100 :<|> sayhi :<|> dbl :<|> serveDirectory "static"
47+server = return () :<|> return 100 :<|> sayhi :<|> dbl :<|> multi :<|> serveDirectory "static"
48 where sayhi nm greetings withGusto = case nm of
48 where sayhi nm greetings withGusto = case nm of
49 Nothing -> return ("Sorry, who are you?" :: String)
49 Nothing -> return ("Sorry, who are you?" :: String)
50 Just n -> do
50 Just n -> do
@@ -56,6 +56,7 @@ server = return () :<|> return 100 :<|> sayhi :<|> dbl :<|> serveDirectory "stat
56 ++ ", and " ++ L.last greetings ++ ", "
56 ++ ", and " ++ L.last greetings ++ ", "
57 return . modifier $ greetPart ++ n
57 return . modifier $ greetPart ++ n
58 dbl x = return $ x * 2
58 dbl x = return $ x * 2
59+ multi = return . bool "Box unchecked" "Box Checked"
59
60
60-- Turn the server into a WAI app. 'serve' is provided by servant,
61-- Turn the server into a WAI app. 'serve' is provided by servant,
61-- more precisely by the Servant.Server module.
62-- more precisely by the Servant.Server module.