INNER CODE UNIT · Go

validateWebhook

prometheus-msteams/prometheus-msteams · cmd/server/main.go:77

func validateWebhook(workflowType service.WebhookType, u string) error {
	path := strings.TrimPrefix(u, "https://")
	if u == path {
		return fmt.Errorf("the webhook_url must start with 'https://'. url: '%s'", u)
	}

	switch workflowType {
	case service.O365:
		isValidTeamsHook := validWebhookPatternO365.MatchString(path) || strings.HasPrefix(path, legacyWebhookPrefix)
		if !isValidTeamsHook {
			return fmt.Errorf("the webhook_url has an unexpected format '%s'", u)
		}
	case service.Workflow:
		isValidTeamsHook := validWebhookPatternWorkflow.MatchString(path)
		if !isValidTeamsHook {
			return fmt.Errorf("the webhook_url has an unexpected format '%s'", u)
		}
		return nil

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…