@@ -17,9 +17,27 @@ import Servant.Docs
17import Servant.Server
17import Servant.Server
19-- | Endpoint for DELETE requests.
19-- | Endpoint for DELETE requests.
23+-- > -- DELETE /books/:isbn
24+-- > type MyApi = "books" :> Capture "isbn" Text :> Delete
26+-- corresponds to a DELETE HTTP request at @/books/:isbn@.
20data Delete
27data Delete
21 deriving Typeable
28 deriving Typeable
30+-- | If you have a 'Delete' endpoint in your API,
31+-- the handler for this endpoint is meant to delete
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
23instance HasServer Delete where
41instance HasServer Delete where
24 type Server Delete = EitherT (Int, String) IO ()
42 type Server Delete = EitherT (Int, String) IO ()
@@ -35,6 +53,10 @@ instance HasServer Delete where
35 respond $ failWith WrongMethod
53 respond $ failWith WrongMethod
36 | otherwise = respond $ failWith NotFound
54 | otherwise = respond $ failWith NotFound
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.
38instance HasClient Delete where
60instance HasClient Delete where
39 type Client Delete = BaseUrl -> EitherT String IO ()
61 type Client Delete = BaseUrl -> EitherT String IO ()