Skip to content

Commit

Permalink
Merge pull request #1035 from afcady/multipart-foreign
Browse files Browse the repository at this point in the history
Implement HasForeign instance
  • Loading branch information
phadej authored Nov 7, 2018
2 parents da2af9f + c07f86b commit 80a047d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions servant-foreign/src/Servant/Foreign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Servant.Foreign
, HeaderArg(..)
, QueryArg(..)
, Req(..)
, ReqBodyContentType(..)
, Segment(..)
, SegmentType(..)
, Url(..)
Expand All @@ -21,6 +22,7 @@ module Servant.Foreign
, reqMethod
, reqHeaders
, reqBody
, reqBodyContentType
, reqReturnType
, reqFuncName
, path
Expand Down
18 changes: 11 additions & 7 deletions servant-foreign/src/Servant/Foreign/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +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
{ _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 [])
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
Expand Down

0 comments on commit 80a047d

Please sign in to comment.