Safe Haskell | Safe-Inferred |
---|---|
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
- 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)
- httpExceptionErrorEncoding :: HttpException -> ByteString
- data RequestDetails = RequestDetails {}
- extractRequest :: RequestDetails -> Request
- isNetworkError :: HTTPErr a -> Bool
- isNetworkErrorHC :: HttpException -> Bool
- 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
- 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
- prepareHeaders :: [EventHeaderInfo] -> ([Header], [HeaderConf])
- getRetryAfterHeaderFromHTTPErr :: HTTPErr a -> Maybe Text
- getRetryAfterHeaderFromResp :: HTTPResp a -> Maybe Text
- parseRetryHeaderValue :: Text -> Maybe Int
Documentation
data ExtraLogContext Source #
ExtraLogContext | |
|
Instances
Show ExtraLogContext Source # | |
Defined in Hasura.Eventing.HTTP showsPrec :: Int -> ExtraLogContext -> ShowS # show :: ExtraLogContext -> String # showList :: [ExtraLogContext] -> ShowS # | |
Eq ExtraLogContext Source # | |
Defined in Hasura.Eventing.HTTP (==) :: ExtraLogContext -> ExtraLogContext -> Bool # (/=) :: ExtraLogContext -> ExtraLogContext -> Bool # |
data HTTPResp (a :: TriggerTypes) Source #
HTTPResp | |
|
Instances
data HTTPErr (a :: TriggerTypes) Source #
Instances
ToJSON (HTTPErr a) Source # | |
Show (HTTPErr a) Source # | |
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 # |
data RequestDetails Source #
Instances
isNetworkError :: HTTPErr a -> Bool Source #
isNetworkErrorHC :: HttpException -> Bool 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 #
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 #
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).