Use BaseUrl and Req instead of Request.
This commit is contained in:
parent
bf9c84eccb
commit
29c9d85ade
1 changed files with 7 additions and 2 deletions
|
@ -48,7 +48,7 @@ import Web.HttpApiData
|
||||||
|
|
||||||
data ServantError
|
data ServantError
|
||||||
= FailureResponse
|
= FailureResponse
|
||||||
{ failingRequest :: Request
|
{ failingRequest :: UrlReq
|
||||||
, responseStatus :: Status
|
, responseStatus :: Status
|
||||||
, responseContentType :: MediaType
|
, responseContentType :: MediaType
|
||||||
, responseBody :: ByteString
|
, responseBody :: ByteString
|
||||||
|
@ -86,6 +86,11 @@ instance Eq ServantError where
|
||||||
|
|
||||||
instance Exception ServantError
|
instance Exception ServantError
|
||||||
|
|
||||||
|
data UrlReq = UrlReq BaseUrl Req
|
||||||
|
|
||||||
|
instance Show UrlReq where
|
||||||
|
show (UrlReq url req) = showBaseUrl url ++ reqPath req ++ "?" ++ show (qs req)
|
||||||
|
|
||||||
data Req = Req
|
data Req = Req
|
||||||
{ reqPath :: String
|
{ reqPath :: String
|
||||||
, qs :: QueryText
|
, qs :: QueryText
|
||||||
|
@ -251,7 +256,7 @@ performRequest reqMethod req = do
|
||||||
Nothing -> throwError $ InvalidContentTypeHeader (cs t) body
|
Nothing -> throwError $ InvalidContentTypeHeader (cs t) body
|
||||||
Just t' -> pure t'
|
Just t' -> pure t'
|
||||||
unless (status_code >= 200 && status_code < 300) $
|
unless (status_code >= 200 && status_code < 300) $
|
||||||
throwError $ FailureResponse request status ct body
|
throwError $ FailureResponse (UrlReq reqHost req) status ct body
|
||||||
return (status_code, body, ct, hdrs, response)
|
return (status_code, body, ct, hdrs, response)
|
||||||
|
|
||||||
performRequestCT :: MimeUnrender ct result => Proxy ct -> Method -> Req
|
performRequestCT :: MimeUnrender ct result => Proxy ct -> Method -> Req
|
||||||
|
|
Loading…
Reference in a new issue