Merge pull request #1035 from afcady/multipart-foreign
Implement HasForeign instance
This commit is contained in:
commit
80a047d1d4
2 changed files with 13 additions and 7 deletions
|
@ -5,6 +5,7 @@ module Servant.Foreign
|
||||||
, HeaderArg(..)
|
, HeaderArg(..)
|
||||||
, QueryArg(..)
|
, QueryArg(..)
|
||||||
, Req(..)
|
, Req(..)
|
||||||
|
, ReqBodyContentType(..)
|
||||||
, Segment(..)
|
, Segment(..)
|
||||||
, SegmentType(..)
|
, SegmentType(..)
|
||||||
, Url(..)
|
, Url(..)
|
||||||
|
@ -21,6 +22,7 @@ module Servant.Foreign
|
||||||
, reqMethod
|
, reqMethod
|
||||||
, reqHeaders
|
, reqHeaders
|
||||||
, reqBody
|
, reqBody
|
||||||
|
, reqBodyContentType
|
||||||
, reqReturnType
|
, reqReturnType
|
||||||
, reqFuncName
|
, reqFuncName
|
||||||
, path
|
, path
|
||||||
|
|
|
@ -123,6 +123,9 @@ defUrl = Url [] []
|
||||||
|
|
||||||
makeLenses ''Url
|
makeLenses ''Url
|
||||||
|
|
||||||
|
data ReqBodyContentType = ReqBodyJSON | ReqBodyMultipart
|
||||||
|
deriving (Data, Eq, Show, Read)
|
||||||
|
|
||||||
data Req f = Req
|
data Req f = Req
|
||||||
{ _reqUrl :: Url f
|
{ _reqUrl :: Url f
|
||||||
, _reqMethod :: HTTP.Method
|
, _reqMethod :: HTTP.Method
|
||||||
|
@ -130,13 +133,14 @@ data Req f = Req
|
||||||
, _reqBody :: Maybe f
|
, _reqBody :: Maybe f
|
||||||
, _reqReturnType :: Maybe f
|
, _reqReturnType :: Maybe f
|
||||||
, _reqFuncName :: FunctionName
|
, _reqFuncName :: FunctionName
|
||||||
|
, _reqBodyContentType :: ReqBodyContentType
|
||||||
}
|
}
|
||||||
deriving (Data, Eq, Show, Typeable)
|
deriving (Data, Eq, Show, Typeable)
|
||||||
|
|
||||||
makeLenses ''Req
|
makeLenses ''Req
|
||||||
|
|
||||||
defReq :: Req ftype
|
defReq :: Req ftype
|
||||||
defReq = Req defUrl "GET" [] Nothing Nothing (FunctionName [])
|
defReq = Req defUrl "GET" [] Nothing Nothing (FunctionName []) ReqBodyJSON
|
||||||
|
|
||||||
-- | 'HasForeignType' maps Haskell types with types in the target
|
-- | 'HasForeignType' maps Haskell types with types in the target
|
||||||
-- language of your backend. For example, let's say you're
|
-- language of your backend. For example, let's say you're
|
||||||
|
|
Loading…
Reference in a new issue