Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hasura.Eventing.HTTP
This module is an utility module providing HTTP utilities for Hasura.Eventing.EventTriggers and Hasura.Eventing.ScheduledTriggers.
The event triggers and scheduled triggers share the event delivery
mechanism using the tryWebhook
function defined in this module.
Synopsis
- retryAfterHeader :: CI Text
- data ExtraLogContext = ExtraLogContext {
- elEventId :: !EventId
- elEventName :: !(Maybe TriggerName)
- data HTTPResp (a :: TriggerTypes) = HTTPResp {
- hrsStatus :: !Int
- hrsHeaders :: ![HeaderConf]
- hrsBody :: !SerializableBlob
- hrsSize :: !Int64
- data HTTPErr (a :: TriggerTypes)
- mkHTTPResp :: Response ByteString -> HTTPResp a
- data RequestDetails = RequestDetails {}
- extractRequest :: RequestDetails -> Request
- data HTTPRespExtra (a :: TriggerTypes) = HTTPRespExtra {
- _hreResponse :: !(Either (HTTPErr a) (HTTPResp a))
- _hreContext :: !ExtraLogContext
- _hreRequest :: !RequestDetails
- _hreWebhookVarName :: !Text
- _hreLogHeaders :: ![HeaderConf]
- isNetworkError :: HTTPErr a -> Bool
- isNetworkErrorHC :: HttpException -> Bool
- anyBodyParser :: Response ByteString -> Either (HTTPErr a) (HTTPResp a)
- data HTTPReq = HTTPReq {}
- logHTTPForET :: (MonadReader r m, Has (Logger Hasura) r, MonadIO m) => Either (HTTPErr 'EventType) (HTTPResp 'EventType) -> ExtraLogContext -> RequestDetails -> Text -> [HeaderConf] -> m ()
- logHTTPForST :: (MonadReader r m, Has (Logger Hasura) r, MonadIO m) => Either (HTTPErr 'ScheduledType) (HTTPResp 'ScheduledType) -> ExtraLogContext -> RequestDetails -> Text -> [HeaderConf] -> m ()
- runHTTP :: MonadIO m => Manager -> Request -> m (Either (HTTPErr a) (HTTPResp a))
- data TransformableRequestError a
- = HTTPError Value (HTTPErr a)
- | TransformationError Value TransformErrorBundle
- mkRequest :: MonadError (TransformableRequestError a) m => [Header] -> ResponseTimeout -> ByteString -> Maybe RequestTransform -> ResolvedWebhook -> m RequestDetails
- invokeRequest :: (MonadReader r m, MonadError (TransformableRequestError a) m, Has Manager r, Has (Logger Hasura) r, MonadIO m, MonadTrace m) => RequestDetails -> Maybe ResponseTransform -> Maybe SessionVariables -> (Either (HTTPErr a) (HTTPResp a) -> RequestDetails -> m ()) -> m (HTTPResp a)
- mkResp :: Int -> SerializableBlob -> [HeaderConf] -> Response a
- mkClientErr :: SerializableBlob -> Response a
- mkWebhookReq :: Value -> [HeaderConf] -> InvocationVersion -> WebhookRequest
- mkInvocationResp :: Maybe Int -> SerializableBlob -> [HeaderConf] -> Response a
- isClientError :: Int -> Bool
- encodeHeader :: EventHeaderInfo -> Header
- decodeHeader :: [EventHeaderInfo] -> (HeaderName, ByteString) -> HeaderConf
- prepareHeaders :: [EventHeaderInfo] -> ([Header], [HeaderConf])
- getRetryAfterHeaderFromHTTPErr :: HTTPErr a -> Maybe Text
- getRetryAfterHeaderFromResp :: HTTPResp a -> Maybe Text
- parseRetryHeaderValue :: Text -> Maybe Int
Documentation
retryAfterHeader :: CI Text Source #
data ExtraLogContext Source #
ExtraLogContext | |
|
Instances
Eq ExtraLogContext Source # | |
Defined in Hasura.Eventing.HTTP (==) :: ExtraLogContext -> ExtraLogContext -> Bool # (/=) :: ExtraLogContext -> ExtraLogContext -> Bool # | |
Show ExtraLogContext Source # | |
Defined in Hasura.Eventing.HTTP showsPrec :: Int -> ExtraLogContext -> ShowS # show :: ExtraLogContext -> String # showList :: [ExtraLogContext] -> ShowS # |
data HTTPResp (a :: TriggerTypes) Source #
HTTPResp | |
|
Instances
Show (HTTPResp a) Source # | |
ToJSON (HTTPResp a) Source # | |
Defined in Hasura.Eventing.HTTP toEncoding :: HTTPResp a -> Encoding toJSONList :: [HTTPResp a] -> Value toEncodingList :: [HTTPResp a] -> Encoding | |
ToEngineLog (HTTPResp 'EventType) Hasura Source # | |
Defined in Hasura.Eventing.HTTP toEngineLog :: HTTPResp 'EventType -> (LogLevel, EngineLogType Hasura, Value) Source # | |
ToEngineLog (HTTPResp 'ScheduledType) Hasura Source # | |
Defined in Hasura.Eventing.HTTP toEngineLog :: HTTPResp 'ScheduledType -> (LogLevel, EngineLogType Hasura, Value) Source # |
data HTTPErr (a :: TriggerTypes) Source #
Instances
Show (HTTPErr a) Source # | |
ToJSON (HTTPErr a) Source # | |
Defined in Hasura.Eventing.HTTP toEncoding :: HTTPErr a -> Encoding toJSONList :: [HTTPErr a] -> Value toEncodingList :: [HTTPErr a] -> Encoding | |
ToEngineLog (HTTPErr 'EventType) Hasura Source # | |
Defined in Hasura.Eventing.HTTP toEngineLog :: HTTPErr 'EventType -> (LogLevel, EngineLogType Hasura, Value) Source # | |
ToEngineLog (HTTPErr 'ScheduledType) Hasura Source # | |
Defined in Hasura.Eventing.HTTP toEngineLog :: HTTPErr 'ScheduledType -> (LogLevel, EngineLogType Hasura, Value) Source # |
mkHTTPResp :: Response ByteString -> HTTPResp a Source #
data RequestDetails Source #
Instances
ToJSON RequestDetails Source # | |
Defined in Hasura.Eventing.HTTP toJSON :: RequestDetails -> Value toEncoding :: RequestDetails -> Encoding toJSONList :: [RequestDetails] -> Value toEncodingList :: [RequestDetails] -> Encoding |
data HTTPRespExtra (a :: TriggerTypes) Source #
HTTPRespExtra | |
|
isNetworkError :: HTTPErr a -> Bool Source #
isNetworkErrorHC :: HttpException -> Bool Source #
anyBodyParser :: Response ByteString -> Either (HTTPErr a) (HTTPResp a) Source #
logHTTPForET :: (MonadReader r m, Has (Logger Hasura) r, MonadIO m) => Either (HTTPErr 'EventType) (HTTPResp 'EventType) -> ExtraLogContext -> RequestDetails -> Text -> [HeaderConf] -> m () Source #
logHTTPForST :: (MonadReader r m, Has (Logger Hasura) r, MonadIO m) => Either (HTTPErr 'ScheduledType) (HTTPResp 'ScheduledType) -> ExtraLogContext -> RequestDetails -> Text -> [HeaderConf] -> m () Source #
data TransformableRequestError a Source #
HTTPError Value (HTTPErr a) | |
TransformationError Value TransformErrorBundle |
Instances
Show (TransformableRequestError a) Source # | |
Defined in Hasura.Eventing.HTTP showsPrec :: Int -> TransformableRequestError a -> ShowS # show :: TransformableRequestError a -> String # showList :: [TransformableRequestError a] -> ShowS # |
:: MonadError (TransformableRequestError a) m | |
=> [Header] | |
-> ResponseTimeout | |
-> ByteString | the request body. It is passed as a |
-> Maybe RequestTransform | |
-> ResolvedWebhook | |
-> m RequestDetails |
invokeRequest :: (MonadReader r m, MonadError (TransformableRequestError a) m, Has Manager r, Has (Logger Hasura) r, MonadIO m, MonadTrace m) => RequestDetails -> Maybe ResponseTransform -> Maybe SessionVariables -> (Either (HTTPErr a) (HTTPResp a) -> RequestDetails -> m ()) -> m (HTTPResp a) Source #
mkResp :: Int -> SerializableBlob -> [HeaderConf] -> Response a Source #
mkClientErr :: SerializableBlob -> Response a Source #
mkWebhookReq :: Value -> [HeaderConf] -> InvocationVersion -> WebhookRequest Source #
mkInvocationResp :: Maybe Int -> SerializableBlob -> [HeaderConf] -> Response a Source #
isClientError :: Int -> Bool Source #
encodeHeader :: EventHeaderInfo -> Header Source #
decodeHeader :: [EventHeaderInfo] -> (HeaderName, ByteString) -> HeaderConf Source #
prepareHeaders :: [EventHeaderInfo] -> ([Header], [HeaderConf]) Source #
Encodes given request headers along with our defaultHeaders
and returns
them along with the re-decoded set of headers (for logging purposes).
getRetryAfterHeaderFromHTTPErr :: HTTPErr a -> Maybe Text Source #
getRetryAfterHeaderFromResp :: HTTPResp a -> Maybe Text Source #
parseRetryHeaderValue :: Text -> Maybe Int Source #