27 lines
588 B
Go
27 lines
588 B
Go
package plugin
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// handleWebhook обрабатывает входящие вебхуки от Sentry
|
|
func (p *Plugin) handleWebhook(w http.ResponseWriter, r *http.Request) {
|
|
defer r.Body.Close()
|
|
|
|
resource := r.Header.Get("Sentry-Hook-Resource")
|
|
|
|
switch resource {
|
|
case "event_alert":
|
|
p.handleEventAlert(w, r)
|
|
case "comment":
|
|
p.handleComment(w, r)
|
|
case "metric_alert":
|
|
p.handleMetricAlert(w, r)
|
|
case "issue":
|
|
p.handleIssue(w, r)
|
|
default:
|
|
p.API.LogWarn("Unsupported Sentry hook resource", "resource", resource)
|
|
w.WriteHeader(http.StatusOK)
|
|
}
|
|
}
|