@@ -17,9 +17,27 @@ import Servant.Docs
1717import Servant.Server
1818
1919-- | Endpoint for DELETE requests.
20+--
21+-- Example:
22+--
23+-- > -- DELETE /books/:isbn
24+-- > type MyApi = "books" :> Capture "isbn" Text :> Delete
25+--
26+-- corresponds to a DELETE HTTP request at @/books/:isbn@.
2027data Delete
2128 deriving Typeable
2229
30+-- | If you have a 'Delete' endpoint in your API,
31+-- the handler for this endpoint is meant to delete
32+-- a resource.
33+--
34+-- The code of the handler will, just like
35+-- for 'Servant.API.Get.Get', 'Servant.API.Post.Post' and
36+-- 'Servant.API.Put.Put', run in @EitherT (Int, String) IO ()@.
37+-- The 'Int' represents the status code and the 'String' a message
38+-- to be returned. You can use 'Control.Monad.Trans.Either.left' to
39+-- painlessly error out if the conditions for a successful deletion
40+-- are not met.
2341instance HasServer Delete where
2442 type Server Delete = EitherT (Int, String) IO ()
2543
@@ -35,6 +53,10 @@ instance HasServer Delete where
3553 respond $ failWith WrongMethod
3654 | otherwise = respond $ failWith NotFound
3755
56+-- | If you have a 'Delete' endpoint in your API, the client
57+-- side querying function that is created when calling 'client'
58+-- will just require an argument that specifies the scheme, host
59+-- and port to send the request to.
3860instance HasClient Delete where
3961 type Client Delete = BaseUrl -> EitherT String IO ()
4062