@@ -258,20 +258,74 @@ instance (KnownSymbol capture, FromText a, HasServer sublayout)
258258-- to be returned. You can use 'Control.Monad.Trans.Either.left' to
259259-- painlessly error out if the conditions for a successful deletion
260260-- are not met.
261−instance HasServer Delete where
261+instance
262+#if MIN_VERSION_base(4,8,0)
263+ {-# OVERLAPPABLE #-}
264+#endif
265+ ( AllCTRender ctypes a
266+ ) => HasServer (Delete ctypes a) where
267+
268+ type ServerT (Delete ctypes a) m = m a
269+
270+ route Proxy action request respond
271+ | pathIsEmpty request && requestMethod request == methodDelete = do
272+ e <- runEitherT action
273+ respond $ case e of
274+ Right output -> do
275+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
276+ case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) output of
277+ Nothing -> failWith UnsupportedMediaType
278+ Just (contentT, body) -> succeedWith $
279+ responseLBS status200 [ ("Content-Type" , cs contentT)] body
280+ Left err -> succeedWith $ responseServantErr err
281+ | pathIsEmpty request && requestMethod request /= methodDelete =
282+ respond $ failWith WrongMethod
283+ | otherwise = respond $ failWith NotFound
284+
285+instance
286+#if MIN_VERSION_base(4,8,0)
287+ {-# OVERLAPPING #-}
288+#endif
289+ HasServer (Delete ctypes ()) where
262290
263− type ServerT Delete m = m ()
291+ type ServerT (Delete ctypes ()) m = m ()
264292
265293 route Proxy action request respond
266294 | pathIsEmpty request && requestMethod request == methodDelete = do
267295 e <- runEitherT action
268− respond $ succeedWith $ case e of
269− Right () -> responseLBS status204 [] ""
296+ respond . succeedWith $ case e of
297+ Right () -> responseLBS noContent204 [] ""
270298 Left err -> responseServantErr err
271299 | pathIsEmpty request && requestMethod request /= methodDelete =
272300 respond $ failWith WrongMethod
273301 | otherwise = respond $ failWith NotFound
274302
303+-- Add response headers
304+instance
305+#if MIN_VERSION_base(4,8,0)
306+ {-# OVERLAPPING #-}
307+#endif
308+ ( GetHeaders (Headers h v), AllCTRender ctypes v
309+ ) => HasServer (Delete ctypes (Headers h v)) where
310+
311+ type ServerT (Delete ctypes (Headers h v)) m = m (Headers h v)
312+
313+ route Proxy action request respond
314+ | pathIsEmpty request && requestMethod request == methodDelete = do
315+ e <- runEitherT action
316+ respond $ case e of
317+ Right output -> do
318+ let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
319+ headers = getHeaders output
320+ case handleAcceptH (Proxy :: Proxy ctypes) (AcceptHeader accH) (getResponse output) of
321+ Nothing -> failWith UnsupportedMediaType
322+ Just (contentT, body) -> succeedWith $
323+ responseLBS status200 ( ("Content-Type" , cs contentT) : headers) body
324+ Left err -> succeedWith $ responseServantErr err
325+ | pathIsEmpty request && requestMethod request /= methodDelete =
326+ respond $ failWith WrongMethod
327+ | otherwise = respond $ failWith NotFound
328+
275329-- | When implementing the handler for a 'Get' endpoint,
276330-- just like for 'Servant.API.Delete.Delete', 'Servant.API.Post.Post'
277331-- and 'Servant.API.Put.Put', the handler code runs in the