git.iko.soy/typeable/servant
on master help sign in
introduce type ReqBodyContentType replacing use of Bool
c07f86bAndrew Cady
servant-foreign/src/Servant/Foreign.hs+2−1
@@ -5,6 +5,7 @@ module Servant.Foreign
5 , HeaderArg(..)
5 , HeaderArg(..)
6 , QueryArg(..)
6 , QueryArg(..)
7 , Req(..)
7 , Req(..)
8+ , ReqBodyContentType(..)
8 , Segment(..)
9 , Segment(..)
9 , SegmentType(..)
10 , SegmentType(..)
10 , Url(..)
11 , Url(..)
@@ -21,7 +22,7 @@ module Servant.Foreign
21 , reqMethod
22 , reqMethod
22 , reqHeaders
23 , reqHeaders
23 , reqBody
24 , reqBody
24− , reqBodyIsJSON
25+ , reqBodyContentType
25 , reqReturnType
26 , reqReturnType
26 , reqFuncName
27 , reqFuncName
27 , path
28 , path
servant-foreign/src/Servant/Foreign/Internal.hs+11−8
@@ -123,21 +123,24 @@ defUrl = Url [] []
123
123
124makeLenses ''Url
124makeLenses ''Url
125
125
126+data ReqBodyContentType = ReqBodyJSON | ReqBodyMultipart
127+ deriving (Data, Eq, Show, Read)
128+
126data Req f = Req
129data Req f = Req
127− { _reqUrl :: Url f
130+ { _reqUrl :: Url f
128− , _reqMethod :: HTTP.Method
131+ , _reqMethod :: HTTP.Method
129− , _reqHeaders :: [HeaderArg f]
132+ , _reqHeaders :: [HeaderArg f]
130− , _reqBody :: Maybe f
133+ , _reqBody :: Maybe f
131− , _reqReturnType :: Maybe f
134+ , _reqReturnType :: Maybe f
132− , _reqFuncName :: FunctionName
135+ , _reqFuncName :: FunctionName
133− , _reqBodyIsJSON :: Bool
136+ , _reqBodyContentType :: ReqBodyContentType
134 }
137 }
135 deriving (Data, Eq, Show, Typeable)
138 deriving (Data, Eq, Show, Typeable)
136
139
137makeLenses ''Req
140makeLenses ''Req
138
141
139defReq :: Req ftype
142defReq :: Req ftype
140−defReq = Req defUrl "GET" [] Nothing Nothing (FunctionName []) True
143+defReq = Req defUrl "GET" [] Nothing Nothing (FunctionName []) ReqBodyJSON
141
144
142-- | 'HasForeignType' maps Haskell types with types in the target
145-- | 'HasForeignType' maps Haskell types with types in the target
143-- language of your backend. For example, let's say you're
146-- language of your backend. For example, let's say you're