Update readme and example for new BaseUrl
commit9d6f5899e265098be891bd7af750d9e9af43cef9
authorGreg Hale <imalsogreg@gmail.com>
dateSun 1 May 2016, 18:09 (10 years ago)
parent43e2180
README.md+1−1
@@ -82,7 +82,7 @@ type API = "getint" :> Get '[JSON] Int
8282 -- servant-reflex computes FRP functions for each API endpoint
8383 let (getint :<|> sayhi :<|> doubleit :<|> _) = client (Proxy :: Proxy API)
8484 (Proxy :: Proxy m)
85− (constDyn defaultUrl)
85+ (constDyn (BasePath "/"))
8686```
8787
8888These client functions are computed from the API and manage serialization, XhrRequest generation, and deserialization for you. `a` parameters become `Behavior t (Maybe a)` values. You provide a trigger event and receive an `Event t (Maybe r, XhrResponse)`, with responses from the API server (which you would write with `servant-server`).
exec/Example.hs+2
@@ -22,6 +22,8 @@ main = mainWidget run
2222run :: forall t m. MonadWidget t m => m ()
2323run = do
2424
25+ -- Allow user to choose the url target for the request
26+ -- (alternatively we could just `let url = constDyn (BasePath "/")`)
2527 url <- baseUrlWidget
2628 el "br" (return ())
2729 dynText =<< mapDyn showBaseUrl url