Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Hasura.Eventing.HTTP
Description
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 #
Constructors
ExtraLogContext | |
Fields
|
Instances
Show ExtraLogContext Source # | |
Defined in Hasura.Eventing.HTTP Methods showsPrec :: Int -> ExtraLogContext -> ShowS # show :: ExtraLogContext -> String # showList :: [ExtraLogContext] -> ShowS # | |
Eq ExtraLogContext Source # | |
Defined in Hasura.Eventing.HTTP Methods (==) :: ExtraLogContext -> ExtraLogContext -> Bool # (/=) :: ExtraLogContext -> ExtraLogContext -> Bool # |
data HTTPResp (a :: TriggerTypes) Source #
Constructors
HTTPResp | |
Fields
|
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 Methods toEngineLog :: HTTPErr 'EventType -> (LogLevel, EngineLogType Hasura, Value) Source # | |
ToEngineLog (HTTPErr 'ScheduledType) Hasura Source # | |
Defined in Hasura.Eventing.HTTP Methods toEngineLog :: HTTPErr 'ScheduledType -> (LogLevel, EngineLogType Hasura, Value) Source # |
data RequestDetails Source #
Constructors
RequestDetails | |
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 #
Constructors
HTTPError Value (HTTPErr a) | |
TransformationError Value TransformErrorBundle |
Instances
Show (TransformableRequestError a) Source # | |
Defined in Hasura.Eventing.HTTP Methods showsPrec :: Int -> TransformableRequestError a -> ShowS # show :: TransformableRequestError a -> String # showList :: [TransformableRequestError a] -> ShowS # |
Arguments
:: 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).