add examples for Put and Post
This commit is contained in:
parent
44974baf79
commit
15adc964e4
2 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue