1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE DeriveDataTypeable #-}
5module Servant.API.Delete where
7import Control.Monad.Trans.Either
9import Data.String.Conversions
11import Network.HTTP.Types
16import Servant.Utils.BaseUrl
17import Servant.Utils.Client
19-- | 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 $ succeedWith $ case e of
31 responseLBS status204 [] ""
32 Left (status, message) ->
33 responseLBS (mkStatus status (cs message)) [] (cs message)
34 | null (pathInfo request) && requestMethod request /= methodDelete =
35 respond $ failWith WrongMethod
36 | otherwise = respond $ failWith NotFound
38instance HasClient Delete where
39 type Client Delete = BaseUrl -> EitherT String IO ()
41 clientWithRoute Proxy req host =
42 performRequest methodDelete req 204 host
44instance HasDocs Delete where
45 docsFor Proxy (endpoint, action) =
46 single endpoint' action'
48 where endpoint' = endpoint & method .~ DocDELETE
50 action' = action & response.respBody .~ Nothing
51 & 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