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
|
-- | Endpoint for POST requests. The type variable represents the type of the
|
||||||
-- response body (not the request body, use 'Servant.API.RQBody.RQBody' for
|
-- response body (not the request body, use 'Servant.API.RQBody.RQBody' for
|
||||||
-- that).
|
-- 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
|
data Post a
|
||||||
deriving Typeable
|
deriving Typeable
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,14 @@ import Servant.Common.Req
|
||||||
import Servant.Docs
|
import Servant.Docs
|
||||||
import Servant.Server
|
import Servant.Server
|
||||||
|
|
||||||
-- | Endpoint for PUT requests. The type @a@ is the type of the
|
-- | Endpoint for PUT requests, usually used to update a ressource.
|
||||||
-- response body that's returned.
|
-- 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
|
data Put a
|
||||||
deriving Typeable
|
deriving Typeable
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue