httpcheck

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httpcheck implements the HTTP(S) monitor type (FA-CHK-10..15).

Index

Constants

View Source
const ClientCertCapability = "http-client-cert"

ClientCertCapability is the node capability of binaries that understand clientCertificate. The API accepts the field only when every voter has it (ADR 0042, section 10).

View Source
const Type = "http"

Type is the monitor type key.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Type     string `json:"type"` // basic | bearer
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Token    string `json:"token,omitempty"`
}

Auth adds Basic or Bearer authentication.

type Checker

type Checker struct {
	// RootCAs overrides the system trust store (tests only).
	RootCAs *x509.CertPool
	// contains filtered or unexported fields
}

Checker runs HTTP(S) checks.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context, env *checker.Env, raw json.RawMessage) checker.Result

Check implements checker.Checker. Every check uses its own transport without keep-alive, so a failing connection setup is never hidden by a reused connection (FA-CHK-11, PF-13).

func (*Checker) ConfigSchema

func (*Checker) ConfigSchema() json.RawMessage

ConfigSchema implements checker.Checker.

func (*Checker) Name

func (*Checker) Name() string

Name implements checker.Checker.

func (*Checker) RequiredClusterCapabilities added in v0.0.3

func (*Checker) RequiredClusterCapabilities(raw json.RawMessage) []string

RequiredClusterCapabilities implements checker.ClusterCapabilityRequirer: a configuration with clientCertificate needs every voter to understand it.

func (*Checker) Targets

func (*Checker) Targets(raw json.RawMessage) ([]checker.Target, error)

Targets implements checker.TargetLister: the host of the URL is the only destination the check connects to (ADR 0030).

func (*Checker) Type

func (*Checker) Type() string

Type implements checker.Checker.

func (*Checker) Validate

func (*Checker) Validate(cfg json.RawMessage) error

Validate implements checker.Checker.

type ClientCertificate added in v0.0.3

type ClientCertificate struct {
	Certificate string `json:"certificate"`
	PrivateKey  string `json:"privateKey"`
}

ClientCertificate is a PEM certificate chain and its PEM private key. The key is marked writeOnly in the schema and therefore stored encrypted.

type Config

type Config struct {
	URL                     string            `json:"url"`
	Method                  string            `json:"method,omitempty"`
	Headers                 map[string]string `json:"headers,omitempty"`
	Body                    string            `json:"body,omitempty"`
	Auth                    *Auth             `json:"auth,omitempty"`
	ExpectedStatus          string            `json:"expectedStatus,omitempty"`
	Keyword                 *Keyword          `json:"keyword,omitempty"`
	JSONPath                *JSONPathCheck    `json:"jsonPath,omitempty"`
	MaxResponseMs           int               `json:"maxResponseMs,omitempty"`
	FollowRedirects         *bool             `json:"followRedirects,omitempty"`
	MaxRedirects            int               `json:"maxRedirects,omitempty"`
	IgnoreTLSErrors         bool              `json:"ignoreTlsErrors,omitempty"`
	TLSExpiryWarningDays    *int              `json:"tlsExpiryWarningDays,omitempty"`
	IPFamily                string            `json:"ipFamily,omitempty"`
	MaxBodyBytes            int               `json:"maxBodyBytes,omitempty"`
	ConnectTimeoutMs        int               `json:"connectTimeoutMs,omitempty"`
	TLSTimeoutMs            int               `json:"tlsTimeoutMs,omitempty"`
	ResponseHeaderTimeoutMs int               `json:"responseHeaderTimeoutMs,omitempty"`
	UserAgent               string            `json:"userAgent,omitempty"`
	// ClientCertificate is presented when the server asks for one (ADR 0042).
	ClientCertificate *ClientCertificate `json:"clientCertificate,omitempty"`
}

Config is the HTTP(S) monitor configuration. Its JSON form is described by schemaJSON; both must change together.

type JSONPathCheck

type JSONPathCheck struct {
	Path     string `json:"path"`
	Expected string `json:"expected"`
}

JSONPathCheck compares the value at a path with an expected string.

type Keyword

type Keyword struct {
	Value         string `json:"value"`
	Mode          string `json:"mode,omitempty"` // contains (default) | notContains
	CaseSensitive bool   `json:"caseSensitive,omitempty"`
}

Keyword checks the presence or absence of a text in the body.

Jump to

Keyboard shortcuts

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