git.iko.soy/typeable/servant
on master help sign in
introduce type ReqBodyContentType replacing use of Bool
commitc07f86bda704438e07d1c3e6c3368fab6cc8a911 authorAndrew Cady <d@jerkface.net> dateMon 17 Sep 2018, 17:19 (8 years ago) parent1937836
2 files changed+13−9
servant-foreign/src/Servant/Foreign.hs+2−1 servant-foreign/src/Servant/Foreign/Internal.hs+11−8
servant-foreign/src/Servant/Foreign.hs+2−1
@@ -5,6 +5,7 @@ module Servant.Foreign
55 , HeaderArg(..)
66 , QueryArg(..)
77 , Req(..)
8+ , ReqBodyContentType(..)
89 , Segment(..)
910 , SegmentType(..)
1011 , Url(..)
@@ -21,7 +22,7 @@ module Servant.Foreign
2122 , reqMethod
2223 , reqHeaders
2324 , reqBody
24− , reqBodyIsJSON
25+ , reqBodyContentType
2526 , reqReturnType
2627 , reqFuncName
2728 , path
servant-foreign/src/Servant/Foreign/Internal.hs+11−8
@@ -123,21 +123,24 @@ defUrl = Url [] []
123123
124124makeLenses ''Url
125125
126+data ReqBodyContentType = ReqBodyJSON | ReqBodyMultipart
127+ deriving (Data, Eq, Show, Read)
128+
126129data Req f = Req
127− { _reqUrl :: Url f
128− , _reqMethod :: HTTP.Method
129− , _reqHeaders :: [HeaderArg f]
130− , _reqBody :: Maybe f
131− , _reqReturnType :: Maybe f
132− , _reqFuncName :: FunctionName
133− , _reqBodyIsJSON :: Bool
130+ { _reqUrl :: Url f
131+ , _reqMethod :: HTTP.Method
132+ , _reqHeaders :: [HeaderArg f]
133+ , _reqBody :: Maybe f
134+ , _reqReturnType :: Maybe f
135+ , _reqFuncName :: FunctionName
136+ , _reqBodyContentType :: ReqBodyContentType
134137 }
135138 deriving (Data, Eq, Show, Typeable)
136139
137140makeLenses ''Req
138141
139142defReq :: Req ftype
140−defReq = Req defUrl "GET" [] Nothing Nothing (FunctionName []) True
143+defReq = Req defUrl "GET" [] Nothing Nothing (FunctionName []) ReqBodyJSON
141144
142145-- | 'HasForeignType' maps Haskell types with types in the target
143146-- language of your backend. For example, let's say you're