From 15adc964e42b8e106337f25b9750bb1b2aff5feb Mon Sep 17 00:00:00 2001 From: Alp Mestanogullari Date: Sat, 22 Nov 2014 17:56:35 +0100 Subject: [PATCH] add examples for Put and Post --- src/Servant/API/Post.hs | 7 +++++++ src/Servant/API/Put.hs | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Servant/API/Post.hs b/src/Servant/API/Post.hs index 7460a9ae..10473c40 100644 --- a/src/Servant/API/Post.hs +++ b/src/Servant/API/Post.hs @@ -20,6 +20,13 @@ import Servant.Server -- | Endpoint for POST requests. The type variable represents the type of the -- response body (not the request body, use 'Servant.API.RQBody.RQBody' for -- that). +-- +-- Example: +-- +-- > -- POST /books +-- > -- with a JSON encoded Book as the request body +-- > -- returning the just-created Book +-- > type MyApi = "books" :> ReqBody Book :> Post Book data Post a deriving Typeable diff --git a/src/Servant/API/Put.hs b/src/Servant/API/Put.hs index 58a8b897..904dd5ef 100644 --- a/src/Servant/API/Put.hs +++ b/src/Servant/API/Put.hs @@ -17,8 +17,14 @@ import Servant.Common.Req import Servant.Docs import Servant.Server --- | Endpoint for PUT requests. The type @a@ is the type of the --- response body that's returned. +-- | Endpoint for PUT requests, usually used to update a ressource. +-- The type @a@ is the type of the response body that's returned. +-- +-- Example: +-- +-- > -- PUT /books/:isbn +-- > -- with a Book as request body, returning the updated Book +-- > type MyApi = "books" :> Capture "isbn" Text :> ReqBody Book :> Put Book data Put a deriving Typeable