http

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClientConfiguration = ClientConfiguration{
	UserAgent: "Grafana",
}
View Source
var ErrInvalidMethod = errors.New("webhook only supports HTTP methods PUT or POST")

Functions

func GetBasicAuthHeader

func GetBasicAuthHeader(user string, password string) string

func NewTLSClient

func NewTLSClient(tlsConfig *tls.Config) *http.Client

NewTLSClient creates a new HTTP client with the provided TLS configuration or with default settings.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(log logging.Logger, cfg ClientConfiguration) *Client

func (*Client) SendWebhook

func (ns *Client) SendWebhook(ctx context.Context, webhook *receivers.SendWebhookSettings) error

type ClientConfiguration

type ClientConfiguration struct {
	UserAgent string
}

type ForkedSender

type ForkedSender struct {
	// contains filtered or unexported fields
}

func NewForkedSender

func NewForkedSender(cli receivers.WebhookSender) *ForkedSender

func (ForkedSender) SendWebhook

type HMACRoundTripper

type HMACRoundTripper struct {
	// contains filtered or unexported fields
}

HMACRoundTripper is an HTTP transport that signs outgoing requests using HMAC SHA256. It can optionally include a timestamp in the signature calculation (if timestampHeader is not empty) and supports custom header names for both the signature and timestamp values.

func NewHMACRoundTripper

func NewHMACRoundTripper(wrapped http.RoundTripper, clk clock.Clock, secret, header, timestampHeader string) (*HMACRoundTripper, error)

NewHMACRoundTripper creates a new HMACRoundTripper that wraps the provided RoundTripper. It signs requests using the provided secret key and places the signature in the specified header. If header is empty, it defaults to "X-Grafana-Alert-Signature". If timestampHeader is non-empty, the current timestamp will be included in the signature calculation and set in the specified header.

func (*HMACRoundTripper) RoundTrip

func (rt *HMACRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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