git.iko.soy/typeable/servant
on master help sign in
update examples for servant-docs. fixes #76
commit46d48946b0482fcaf8e7e7f84bbe7ce9d1ddbcdc authorAlp Mestanogullari <alpmestan@gmail.com> dateThu 14 May 2015, 01:01 (11 years ago) parentff6c04c
2 files changed+6−5
servant-docs/README.md+2−2 servant-docs/src/Servant/Docs.hs+4−3
servant-docs/README.md+2−2
@@ -32,7 +32,7 @@ instance ToJSON Greet
3232
3333-- We can also implement 'MimeRender' explicitly for additional formats.
3434instance MimeRender PlainText Greet where
35− toByteString Proxy (Greet s) = "<h1>" <> cs s <> "</h1>"
35+ mimeRender Proxy (Greet s) = "<h1>" <> cs s <> "</h1>"
3636
3737-- we provide a sample value for the 'Greet' type
3838instance ToSample Greet where
@@ -56,7 +56,7 @@ instance ToCapture (Capture "greetid" Text) where
5656type TestApi =
5757 "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get '[JSON,PlainText] Greet
5858 :<|> "greet" :> RQBody '[JSON] Greet :> Post '[JSON] Greet
59− :<|> "delete" :> Capture "greetid" Text :> Delete
59+ :<|> "delete" :> Capture "greetid" Text :> Delete '[] ()
6060
6161testApi :: Proxy TestApi
6262testApi = Proxy
servant-docs/src/Servant/Docs.hs+4−3
@@ -30,6 +30,7 @@
3030-- > {-# LANGUAGE OverloadedStrings #-}
3131-- > {-# LANGUAGE TypeOperators #-}
3232-- > {-# OPTIONS_GHC -fno-warn-orphans #-}
33+-- > import Control.Lens
3334-- > import Data.Aeson
3435-- > import Data.Proxy
3536-- > import Data.String.Conversions
@@ -51,7 +52,7 @@
5152-- >
5253-- > -- | We can also implement 'MimeRender' for additional formats like 'PlainText'.
5354-- > instance MimeRender PlainText Greet where
54−-- > toByteString Proxy (Greet s) = "\"" <> cs s <> "\""
55+-- > mimeRender Proxy (Greet s) = "\"" <> cs s <> "\""
5556-- >
5657-- > -- We add some useful annotations to our captures,
5758-- > -- query parameters and request body to make the docs
@@ -111,7 +112,7 @@
111112-- > :<|> "greet" :> ReqBody '[JSON] Greet :> Post '[JSON] Greet
112113-- >
113114-- > -- DELETE /greet/:greetid
114−-- > :<|> "greet" :> Capture "greetid" Text :> Delete
115+-- > :<|> "greet" :> Capture "greetid" Text :> Delete '[JSON] ()
115116-- >
116117-- > testApi :: Proxy TestApi
117118-- > testApi = Proxy
@@ -121,7 +122,7 @@
121122-- > -- notes.
122123-- > extra :: ExtraInfo TestApi
123124-- > extra =
124−-- > extraInfo (Proxy :: Proxy ("greet" :> Capture "greetid" Text :> Delete)) $
125+-- > extraInfo (Proxy :: Proxy ("greet" :> Capture "greetid" Text :> Delete '[JSON] ())) $
125126-- > defAction & headers <>~ ["unicorns"]
126127-- > & notes <>~ [ DocNote "Title" ["This is some text"]
127128-- > , DocNote "Second secton" ["And some more"]