Parametrize Request

This commit is contained in:
Julian K. Arni 2017-09-14 13:17:19 -04:00
parent 65c2cbb6a9
commit 30528a8198
2 changed files with 8 additions and 4 deletions

View file

@ -20,7 +20,8 @@ module Servant.Client.Core
, HasClient(..) , HasClient(..)
-- * Request -- * Request
, Request(..) , Request
, RequestF(..)
, defaultRequest , defaultRequest
, RequestBody(..) , RequestBody(..)

View file

@ -1,6 +1,7 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
@ -43,15 +44,17 @@ data ServantError =
| ConnectionError Text | ConnectionError Text
deriving (Eq, Show, Generic, Typeable) deriving (Eq, Show, Generic, Typeable)
data Request = Request data RequestF a = Request
{ requestPath :: Builder.Builder { requestPath :: a
, requestQueryString :: Seq.Seq QueryItem , requestQueryString :: Seq.Seq QueryItem
, requestBody :: Maybe (RequestBody, MediaType) , requestBody :: Maybe (RequestBody, MediaType)
, requestAccept :: Seq.Seq MediaType , requestAccept :: Seq.Seq MediaType
, requestHeaders :: Seq.Seq Header , requestHeaders :: Seq.Seq Header
, requestHttpVersion :: HttpVersion , requestHttpVersion :: HttpVersion
, requestMethod :: Method , requestMethod :: Method
} deriving (Generic, Typeable) } deriving (Eq, Show, Functor, Generic, Typeable)
type Request = RequestF Builder.Builder
-- | The request body. Currently only lazy ByteStrings are supported. -- | The request body. Currently only lazy ByteStrings are supported.
newtype RequestBody = RequestBodyLBS LBS.ByteString newtype RequestBody = RequestBodyLBS LBS.ByteString