module Polysemy.Http.Data.Response (
module Polysemy.Http.Data.Response,
Status(Status),
) where
import Network.HTTP.Client (BodyReader)
import Network.HTTP.Types (
Status(Status),
statusIsClientError,
statusIsInformational,
statusIsRedirection,
statusIsServerError,
statusIsSuccessful,
)
import qualified Text.Show as Text (Show(show))
import Polysemy.Http.Data.Header (Header)
data Response b =
Response {
Response b -> Status
status :: Status,
Response b -> b
body :: b,
:: [Header]
}
deriving (Response b -> Response b -> Bool
(Response b -> Response b -> Bool)
-> (Response b -> Response b -> Bool) -> Eq (Response b)
forall b. Eq b => Response b -> Response b -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Response b -> Response b -> Bool
$c/= :: forall b. Eq b => Response b -> Response b -> Bool
== :: Response b -> Response b -> Bool
$c== :: forall b. Eq b => Response b -> Response b -> Bool
Eq, Int -> Response b -> ShowS
[Response b] -> ShowS
Response b -> String
(Int -> Response b -> ShowS)
-> (Response b -> String)
-> ([Response b] -> ShowS)
-> Show (Response b)
forall b. Show b => Int -> Response b -> ShowS
forall b. Show b => [Response b] -> ShowS
forall b. Show b => Response b -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Response b] -> ShowS
$cshowList :: forall b. Show b => [Response b] -> ShowS
show :: Response b -> String
$cshow :: forall b. Show b => Response b -> String
showsPrec :: Int -> Response b -> ShowS
$cshowsPrec :: forall b. Show b => Int -> Response b -> ShowS
Show)
instance {-# OVERLAPPING #-} Show (Response BodyReader) where
show :: Response BodyReader -> String
show (Response s :: Status
s _ hs :: [Header]
hs) =
[qt|StreamingResponse { status :: #{s}, headers :: #{hs} }|]
pattern Info ::
Status ->
b ->
[Header] ->
Response b
pattern $mInfo :: forall r b.
Response b -> (Status -> b -> [Header] -> r) -> (Void# -> r) -> r
Info s b h <- Response s@(statusIsInformational -> True) b h
pattern Success ::
Status ->
b ->
[Header] ->
Response b
pattern $mSuccess :: forall r b.
Response b -> (Status -> b -> [Header] -> r) -> (Void# -> r) -> r
Success s b h <- Response s@(statusIsSuccessful -> True) b h
pattern Redirect ::
Status ->
b ->
[Header] ->
Response b
pattern $mRedirect :: forall r b.
Response b -> (Status -> b -> [Header] -> r) -> (Void# -> r) -> r
Redirect s b h <- Response s@(statusIsRedirection -> True) b h
pattern Client ::
Status ->
b ->
[Header] ->
Response b
pattern $mClient :: forall r b.
Response b -> (Status -> b -> [Header] -> r) -> (Void# -> r) -> r
Client s b h <- Response s@(statusIsClientError -> True) b h
pattern Server ::
Status ->
b ->
[Header] ->
Response b
pattern $mServer :: forall r b.
Response b -> (Status -> b -> [Header] -> r) -> (Void# -> r) -> r
Server s b h <- Response s@(statusIsServerError -> True) b h