@@ -75,10 +75,12 @@ import Servant.API
7575 IsSecure (..), QueryFlag, QueryParam', QueryParams, Raw,
7676 ReflectMethod (reflectMethod), RemoteHost, ReqBody',
7777 SBool (..), SBoolI (..), SourceIO, Stream, StreamBody',
78− Summary, ToSourceIO (..), Vault, Verb, WithNamedContext)
78+ Summary, ToSourceIO (..), Vault, Verb, NoContentVerb,
79+ WithNamedContext)
7980import Servant.API.ContentTypes
8081 (AcceptHeader (..), AllCTRender (..), AllCTUnrender (..),
81− AllMime, MimeRender (..), MimeUnrender (..), canHandleAcceptH)
82+ AllMime, MimeRender (..), MimeUnrender (..), canHandleAcceptH,
83+ NoContent (NoContent))
8284import Servant.API.Modifiers
8385 (FoldLenient, FoldRequired, RequestArgument,
8486 unfoldRequestArgument)
@@ -262,6 +264,17 @@ methodRouter splitHeaders method proxy status action = leafRouter route'
262264 let bdy = if allowedMethodHead method request then "" else body
263265 in Route $ responseLBS status ((hContentType, cs contentT) : headers) bdy
264266
267+noContentRouter :: Method
268+ -> Status
269+ -> Delayed env (Handler b)
270+ -> Router env
271+noContentRouter method status action = leafRouter route'
272+ where
273+ route' env request respond =
274+ runAction (action `addMethodCheck` methodCheck method request)
275+ env request respond $ \ output ->
276+ Route $ responseLBS status [] ""
277+
265278instance {-# OVERLAPPABLE #-}
266279 ( AllCTRender ctypes a, ReflectMethod method, KnownNat status
267280 ) => HasServer (Verb method status ctypes a) context where
@@ -285,6 +298,15 @@ instance {-# OVERLAPPING #-}
285298 where method = reflectMethod (Proxy :: Proxy method)
286299 status = toEnum . fromInteger $ natVal (Proxy :: Proxy status)
287300
301+instance {-# OVERLAPPABLE #-}
302+ (ReflectMethod method
303+ ) => HasServer (NoContentVerb method) context where
304+
305+ type ServerT (NoContentVerb method) m = m NoContent
306+ hoistServerWithContext _ _ nt s = nt s
307+
308+ route Proxy _ = noContentRouter method status204
309+ where method = reflectMethod (Proxy :: Proxy method)
288310
289311instance {-# OVERLAPPABLE #-}
290312 ( MimeRender ctype chunk, ReflectMethod method, KnownNat status,