1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4module Servant.API.Delete where
7import Control.Monad.IO.Class
8import Control.Monad.Trans.Either
10import Data.String.Conversions
11import Network.HTTP.Types
18import qualified Network.HTTP.Client as Client
20-- | Endpoint for DELETE requests.
23instance HasServer Delete where
24 type Server Delete = EitherT (Int, String) IO ()
26 route Proxy action request respond
27 | null (pathInfo request) && requestMethod request == methodDelete = do
28 e <- runEitherT action
29 respond $ Just $ case e of
31 responseLBS status204 [] ""
32 Left (status, message) ->
33 responseLBS (mkStatus status (cs message)) [] (cs message)
34 | otherwise = respond Nothing
36instance HasClient Delete where
37 type Client Delete = URI -> EitherT String IO ()
39 clientWithRoute Proxy req uri = do
40 partialRequest <- liftIO $ reqToRequest req uri
42 let request = partialRequest { Client.method = methodDelete
45 innerResponse <- liftIO . __withGlobalManager $ \ manager ->
46 Client.httpLbs request manager
48 when (Client.responseStatus innerResponse /= status204) $
49 left ("HTTP DELETE request failed with status: " ++ show (Client.responseStatus innerResponse))
51instance HasDocs Delete where
52 docsFor Proxy (endpoint, action) =
53 single endpoint' action'
55 where endpoint' = endpoint & method .~ DocDELETE
57 action' = action & response.respBody .~ Nothing
58 & response.respStatus .~ 204
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list