feat: add incoming webhook API support with configurable endpoints
- Implemented the incoming webhook API to handle alerts from external applications. - Added configuration options for webhook listening address, port, and endpoints in config.go. - Created WebhookReceiverConfig and WebhookEndpointConfig structures to manage webhook settings. - Developed WebhookHandler to process incoming requests, validate tokens, and deliver alerts to specified channels. - Enhanced existing controller interfaces to support alert delivery. - Updated message rendering to respect Markdown settings for different channels. - Added tests for webhook functionality and ensured proper error handling.
This commit is contained in:
@@ -107,6 +107,17 @@ func LoadGlobalConfig(configPath string) (*Config, error) {
|
||||
cfg.ControllerMethod.Webhook.Headers = map[string]string{}
|
||||
}
|
||||
|
||||
// Apply defaults for the incoming webhook API.
|
||||
if cfg.Webhook.ListenAddr == "" {
|
||||
cfg.Webhook.ListenAddr = "0.0.0.0"
|
||||
}
|
||||
if cfg.Webhook.ListenPort == "" {
|
||||
cfg.Webhook.ListenPort = "8081"
|
||||
}
|
||||
if cfg.Webhook.Endpoints == nil {
|
||||
cfg.Webhook.Endpoints = map[string]WebhookEndpointConfig{}
|
||||
}
|
||||
|
||||
// Apply defaults for paths.
|
||||
if cfg.DataPath == "" {
|
||||
cfg.DataPath = "./data"
|
||||
|
||||
Reference in New Issue
Block a user