Documentation ¶
Index ¶
Constants ¶
View Source
const ( DisplayName = "Apteligent" HandlerKey = "apteligent" MessageDirection = "out" MessageBodyType = models.JSON )
Variables ¶
This section is empty.
Functions ¶
func ExampleMessage ¶
func ExampleMessage(cfg config.Configuration, data util.ExampleData, eventSlug string) (cc.Message, error)
func NewHandler ¶
func Normalize ¶
func Normalize(cfg config.Configuration, hReq handlers.HandlerRequest) (cc.Message, error)
// FastHttp request handler for Travis CI outbound webhook
type Handler struct { handlers.Handler //Config config.Configuration //AdapterSet adapters.AdapterSet }
// FastHttp request handler constructor for outbound webhook
func NewHandler(cfg config.Configuration, adapterSet adapters.AdapterSet) Handler { h := Handler{} h.Config = cfg h.AdapterSet = adapterSet h.Normalize = Normalize return h }
func (h Handler) HandlerKey() string { return HandlerKey }
func (h Handler) MessageDirection() string { return MessageDirection }
func (h Handler) HandleEawsyLambda(event *apigatewayproxyevt.Event, ctx *runtime.Context) (models.AwsAPIGatewayProxyOutput, error) { hookData := models.HookDataFromEawsyLambdaEvent(models.JSON, event) errs := h.HandleCanonical(hookData) return models.ErrorInfosToAwsAPIGatewayProxyOutput(errs...), nil }
// HandleFastHTTP is the method to respond to a fasthttp request.
func (h Handler) HandleFastHTTP(ctx *fasthttp.RequestCtx) { hookData := models.HookDataFromFastHTTPReqCtx(models.JSON, ctx) errs := h.HandleCanonical(hookData) proxyOutput := models.ErrorInfosToAwsAPIGatewayProxyOutput(errs...) ctx.SetStatusCode(proxyOutput.StatusCode) if proxyOutput.StatusCode > 399 { fmt.Fprintf(ctx, "%s", proxyOutput.Body) } }
// HandleCanonical is the method to handle a processed request.
func (h Handler) HandleCanonical(hookData models.HookData) []models.ErrorInfo { log.WithFields(log.Fields{ "event": "incoming.webhook", "handler": DisplayName}).Info("HANDLE_FASTHTTP") log.WithFields(log.Fields{ "event": "incoming.webhook", "handler": DisplayName}).Info(string(hookData.InputBody)) ccMsg, err := Normalize(h.Config, hookData.InputBody) if err != nil { //ctx.SetStatusCode(fasthttp.StatusNotAcceptable) log.WithFields(log.Fields{ "type": "http.response", "status": fasthttp.StatusNotAcceptable, "errorMessage": err.Error(), }).Info(fmt.Sprintf("%v request conversion failed.", DisplayName)) return []models.ErrorInfo{{StatusCode: 500, Body: []byte(err.Error())}} } hookData.OutputMessage = ccMsg return h.AdapterSet.SendWebhooks(hookData) }
Types ¶
type ApteligentOutMessage ¶
type ApteligentOutMessage struct { ThresholdValue string `json:"threshold_value,omitempty"` TriggeringValue string `json:"triggering_value,omitempty"` IncidentTime string `json:"incident_time,omitempty"` Description string `json:"description,omitempty"` Metric string `json:"metric,omitempty"` CrittercismAppID string `json:"crittercism_app_id,omitempty"` TriggerID string `json:"trigger_id,omitempty"` State string `json:"state,omitempty"` AlertURL string `json:"alert_url,omitempty"` Filters string `json:"filters,omitempty"` ApplicationName string `json:"application_name,omitempty"` }
func ApteligentOutMessageFromBytes ¶
func ApteligentOutMessageFromBytes(bytes []byte) (ApteligentOutMessage, error)
{ "threshold_value":"1", "description":"The Crashes alert on Crittercism was resolved at 06:40 PM UTC.", "metric":"Crashes", "crittercism_app_id":"54aab27451de5e9f042ec7ee", "trigger_id":"54aabecc1787845ae400000f", "state":"RESOLVED", "alert_url":"https://app.crittercism.com/developers/alerts/54aab27451de5e9f042ec7ee?alertId=54aabecc1787845ae400000f", "filters":"{}", "application_name":"Crittercism" }
{ "threshold_value":"1", "triggering_value":"4", "incident_time":"2015-01-05T18:15:56.976000", "description":"Alert on Crittercism at 06:15 PM UTC. Crashes threshold 4 exceeds 1.", "metric":"Crashes", "crittercism_app_id":"54aab27451de5e9f042ec7ee", "trigger_id":"54aabecc1787845ae400000f", "state":"TRIGGERED", "alert_url":"https://app.crittercism.com/developers/alerts/54aab27451de5e9f042ec7ee?incidentId=54aad4dcf39917103e0041b6", "filters":"{}", "application_name":"Crittercism" }
Click to show internal directories.
Click to hide internal directories.