From c07f86bda704438e07d1c3e6c3368fab6cc8a911 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 17 Sep 2018 17:19:41 -0400 Subject: [PATCH] introduce type ReqBodyContentType replacing use of Bool --- servant-foreign/src/Servant/Foreign.hs | 3 ++- .../src/Servant/Foreign/Internal.hs | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/servant-foreign/src/Servant/Foreign.hs b/servant-foreign/src/Servant/Foreign.hs index f17c8a4f..aa1a5573 100644 --- a/servant-foreign/src/Servant/Foreign.hs +++ b/servant-foreign/src/Servant/Foreign.hs @@ -5,6 +5,7 @@ module Servant.Foreign , HeaderArg(..) , QueryArg(..) , Req(..) + , ReqBodyContentType(..) , Segment(..) , SegmentType(..) , Url(..) @@ -21,7 +22,7 @@ module Servant.Foreign , reqMethod , reqHeaders , reqBody - , reqBodyIsJSON + , reqBodyContentType , reqReturnType , reqFuncName , path diff --git a/servant-foreign/src/Servant/Foreign/Internal.hs b/servant-foreign/src/Servant/Foreign/Internal.hs index 4183a9f5..4f2ff463 100644 --- a/servant-foreign/src/Servant/Foreign/Internal.hs +++ b/servant-foreign/src/Servant/Foreign/Internal.hs @@ -123,21 +123,24 @@ defUrl = Url [] [] makeLenses ''Url +data ReqBodyContentType = ReqBodyJSON | ReqBodyMultipart + deriving (Data, Eq, Show, Read) + data Req f = Req - { _reqUrl :: Url f - , _reqMethod :: HTTP.Method - , _reqHeaders :: [HeaderArg f] - , _reqBody :: Maybe f - , _reqReturnType :: Maybe f - , _reqFuncName :: FunctionName - , _reqBodyIsJSON :: Bool + { _reqUrl :: Url f + , _reqMethod :: HTTP.Method + , _reqHeaders :: [HeaderArg f] + , _reqBody :: Maybe f + , _reqReturnType :: Maybe f + , _reqFuncName :: FunctionName + , _reqBodyContentType :: ReqBodyContentType } deriving (Data, Eq, Show, Typeable) makeLenses ''Req defReq :: Req ftype -defReq = Req defUrl "GET" [] Nothing Nothing (FunctionName []) True +defReq = Req defUrl "GET" [] Nothing Nothing (FunctionName []) ReqBodyJSON -- | 'HasForeignType' maps Haskell types with types in the target -- language of your backend. For example, let's say you're