webhook_sender

package
v0.0.0-...-bad022f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestTimeout           = 10 * time.Second
	MaxResponseBodyBytes     = 64 * 1024
	MaxCapturedResponseBytes = 2 * 1024
)
View Source
const MaxRenderedBodyBytes = 256 * 1024

Variables

This section is empty.

Functions

func BuildWebhookPayload

func BuildWebhookPayload(method string, title string, text string) (any, error)

func NormalizeToText

func NormalizeToText(s string) string

func RenderBody

func RenderBody(input RenderRequest) ([]byte, error)

func SendWebhookRequest

func SendWebhookRequest(method string, url string, payload any, transport *http.Transport) error

Types

type BodyFormat

type BodyFormat string
const (
	BodyJSON BodyFormat = "json"
	BodyForm BodyFormat = "form"
	BodyText BodyFormat = "text"
)

type FormField

type FormField struct {
	Key   string
	Value string
}

type IPResolver

type IPResolver interface {
	LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)
}

type Preset

type Preset string
const (
	PresetGeneric Preset = "generic"
	PresetSlack   Preset = "slack"
	PresetDiscord Preset = "discord"
	PresetTeams   Preset = "teams"
)

func ResolvePreset

func ResolvePreset(value string) (Preset, error)

type RenderRequest

type RenderRequest struct {
	Format   BodyFormat
	Template string
	Fields   []FormField
	Data     TemplateData
}

type Request

type Request struct {
	URL             string
	Preset          Preset
	Format          BodyFormat
	Body            []byte
	Headers         map[string]string
	Transport       *http.Transport
	Resolver        IPResolver
	CaptureResponse bool
}

type Result

type Result struct {
	StatusCode   int
	ResponseSize int
	Duration     time.Duration
	Response     string
}

func Execute

func Execute(ctx context.Context, input Request) (Result, error)

type TemplateData

type TemplateData struct {
	Title     string
	Message   string
	Type      string
	Timestamp time.Time
	NodeName  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL