@@ -26,8 +26,8 @@ import GHC.TypeLits
26import Network.HTTP.Media
26import Network.HTTP.Media
27import qualified Network.HTTP.Types as H
27import qualified Network.HTTP.Types as H
28import Servant.API
28import Servant.API
29+import Servant.API.ContentTypes
29import Servant.Common.BaseUrl
30import Servant.Common.BaseUrl
30−import Servant.Server.ContentTypes
31import Servant.Common.Req
31import Servant.Common.Req
32import Servant.Common.Text
32import Servant.Common.Text
@@ -438,15 +438,16 @@ instance HasClient Raw where
438-- > addBook :: Book -> BaseUrl -> EitherT String IO Book
438-- > addBook :: Book -> BaseUrl -> EitherT String IO Book
439-- > addBook = client myApi
439-- > addBook = client myApi
440-- > -- then you can just use "addBook" to query that endpoint
440-- > -- then you can just use "addBook" to query that endpoint
441−instance (ToJSON a, HasClient sublayout)
441+instance (MimeRender ct a, HasClient sublayout)
442 => HasClient (ReqBody (ct ': cts) a :> sublayout) where
442 => HasClient (ReqBody (ct ': cts) a :> sublayout) where
444 type Client (ReqBody (ct ': cts) a :> sublayout) =
444 type Client (ReqBody (ct ': cts) a :> sublayout) =
445 a -> Client sublayout
445 a -> Client sublayout
447 clientWithRoute Proxy req body =
447 clientWithRoute Proxy req body =
448− clientWithRoute (Proxy :: Proxy sublayout) $
448+ clientWithRoute (Proxy :: Proxy sublayout) $ do
449− setRQBody (encode body) ("application" // "json" /: ("charset", "utf-8")) req
449+ let ctProxy = Proxy :: Proxy ct
450+ setRQBody (toByteString ctProxy body) (contentType ctProxy) req
451-- | Make the querying function append @path@ to the request path.
452-- | Make the querying function append @path@ to the request path.
452instance (KnownSymbol path, HasClient sublayout) => HasClient (path :> sublayout) where
453instance (KnownSymbol path, HasClient sublayout) => HasClient (path :> sublayout) where