Allow () endpoints to have empty content types

This commit is contained in:
Greg Hale 2018-01-10 20:31:01 -05:00
parent 153d3254be
commit 9e40c96df8
3 changed files with 25 additions and 1 deletions

View File

@ -42,7 +42,7 @@ library
reflex-dom == 0.4 && < 0.5,
safe >= 0.3.9 && < 0.4,
servant >= 0.8 && < 0.12,
servant-auth >= 0.2.1 && < 0.3,
servant-auth >= 0.2.1 && < 0.4,
string-conversions >= 0.4 && < 0.5,
text >= 1.2 && < 1.3,
transformers >= 0.4 && < 0.6

View File

@ -163,6 +163,17 @@ instance (SupportsServantReflex t m, ToHttpApiData a, HasClient t m sublayout ta
where p = (fmap . fmap) (toUrlPiece) val
instance {-# OVERLAPPABLE #-}
(ReflectMethod method, SupportsServantReflex t m
) => HasClient t m (Verb method status cts' ()) tag where
type Client t m (Verb method status cts' ()) tag =
Event t tag -> m (Event t (ReqResult tag ()))
clientWithRoute Proxy _ _ req baseurl opts trigs =
fmap ((() <$) . runIdentity) <$> performRequestsNoBody method (constDyn $ Identity $ req') baseurl opts trigs
where method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
req' = req { reqMethod = method }
-- VERB (Returning content) --
instance {-# OVERLAPPABLE #-}
-- Note [Non-Empty Content Types]

View File

@ -150,6 +150,19 @@ instance {-# OVERLAPPABLE #-}
reqs' = fmap (\r -> r { reqMethod = method }) <$> reqs
instance {-# OVERLAPPABLE #-}
(ReflectMethod method,
SupportsServantReflex t m,
Applicative f,
Traversable f
) => HasClientMulti t m (Verb method status cts' ()) f tag where
type ClientMulti t m (Verb method status cts' ()) f tag =
Event t tag -> m (Event t (f (ReqResult tag ())))
clientWithRouteMulti Proxy _ _ _ req baseurl opts vals =
(fmap . fmap . fmap) (() <$) $ performRequestsNoBody method req baseurl opts vals
where method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
------------------------------------------------------------------------------
-- -- VERB (No content) --
instance {-# OVERLAPPING #-}