client: Parameterize RequestF on request body type

This allows us to provide an NFData instance for RequestF, which will
later be useful when we capture the request in FailureResponse.
This commit is contained in:
Ben Gamari 2019-02-03 11:17:08 -05:00
parent 109f7b2a45
commit aa704596be
2 changed files with 21 additions and 4 deletions

View file

@ -1,6 +1,13 @@
[The latest version of this document is on GitHub.](https://github.com/haskell-servant/servant/blob/master/servant-client-core/CHANGELOG.md) [The latest version of this document is on GitHub.](https://github.com/haskell-servant/servant/blob/master/servant-client-core/CHANGELOG.md)
[Changelog for `servant` package contains significant entries for all core packages.](https://github.com/haskell-servant/servant/blob/master/servant/CHANGELOG.md) [Changelog for `servant` package contains significant entries for all core packages.](https://github.com/haskell-servant/servant/blob/master/servant/CHANGELOG.md)
0.15.1
------
- `RequestF` is now parametrized on the request body type as well as the path
type.
0.15 0.15
---- ----

View file

@ -75,17 +75,27 @@ instance NFData ServantError where
rnf (InvalidContentTypeHeader res) = rnf res rnf (InvalidContentTypeHeader res) = rnf res
rnf (ConnectionError err) = rnf err rnf (ConnectionError err) = rnf err
data RequestF a = Request data RequestF body path = Request
{ requestPath :: a { requestPath :: path
, requestQueryString :: Seq.Seq QueryItem , requestQueryString :: Seq.Seq QueryItem
, requestBody :: Maybe (RequestBody, MediaType) , requestBody :: Maybe (body, 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 (Generic, Typeable)
type Request = RequestF Builder.Builder instance (NFData path, NFData body) => NFData (Request body path) where
rnf r =
rnf (requestPath r)
`seq` rnf (requestQueryString r)
`seq` rnf (requestBody r)
`seq` rnf (requestAccept r)
`seq` rnf (requestHeaders r)
`seq` rnf (requestHttpVersion r)
`seq` rnf (requestMethod r)
type Request = RequestF RequestBody Builder.Builder
-- | The request body. A replica of the @http-client@ @RequestBody@. -- | The request body. A replica of the @http-client@ @RequestBody@.
data RequestBody data RequestBody