on master help sign in
add examples for Put and Post
commit15adc964e42b8e106337f25b9750bb1b2aff5feb authorAlp Mestanogullari <alpmestan@gmail.com> dateSat 22 Nov 2014, 17:56 (12 years ago) parent44974ba
2 files changed+15−2
src/Servant/API/Post.hs+7 src/Servant/API/Put.hs+8−2
src/Servant/API/Post.hs+7
@@ -20,6 +20,13 @@ import Servant.Server
2020-- | Endpoint for POST requests. The type variable represents the type of the
2121-- response body (not the request body, use 'Servant.API.RQBody.RQBody' for
2222-- that).
23+--
24+-- Example:
25+--
26+-- > -- POST /books
27+-- > -- with a JSON encoded Book as the request body
28+-- > -- returning the just-created Book
29+-- > type MyApi = "books" :> ReqBody Book :> Post Book
2330data Post a
2431 deriving Typeable
2532
src/Servant/API/Put.hs+8−2
@@ -17,8 +17,14 @@ import Servant.Common.Req
1717import Servant.Docs
1818import Servant.Server
1919
20−-- | Endpoint for PUT requests. The type @a@ is the type of the
21−-- response body that's returned.
20+-- | Endpoint for PUT requests, usually used to update a ressource.
21+-- The type @a@ is the type of the response body that's returned.
22+--
23+-- Example:
24+--
25+-- > -- PUT /books/:isbn
26+-- > -- with a Book as request body, returning the updated Book
27+-- > type MyApi = "books" :> Capture "isbn" Text :> ReqBody Book :> Put Book
2228data Put a
2329 deriving Typeable
2430