injectproxy

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 32 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrQueryParse is returned when the input query is invalid.
	ErrQueryParse = errors.New("failed to parse query string")

	// ErrIllegalLabelMatcher is returned when the input query contains a conflicting label matcher.
	ErrIllegalLabelMatcher = errors.New("conflicting label matcher")

	// ErrEnforceLabel is returned when the label matchers couldn't be enforced.
	ErrEnforceLabel = errors.New("failed to enforce label")
)

Functions

func MustLabelValue added in v0.6.0

func MustLabelValue(ctx context.Context) string

MustLabelValue returns the first (alphabetical order) label value previously stored using WithLabelValue() from the given context. Similar to MustLabelValues, it will panic if no label is found or the value is empty.

func MustLabelValues added in v0.7.0

func MustLabelValues(ctx context.Context) []string

MustLabelValues returns labels (previously stored using WithLabelValue()) from the given context. It will panic if no label is found or the value is empty.

func NewRoutes

func NewRoutes(upstream *url.URL, label string, extractLabeler ExtractLabeler, opts ...Option) (*routes, error)

func WithLabelValues added in v0.7.0

func WithLabelValues(ctx context.Context, labels []string) context.Context

WithLabelValues stores labels in the given context.

Types

type ExtractLabeler added in v0.6.0

type ExtractLabeler interface {
	ExtractLabel(next http.HandlerFunc) http.Handler
}

ExtractLabeler is an HTTP handler that extract the label value to be enforced from the HTTP request. If a valid label value is found, it should store it in the request's context. Otherwise it should return an error in the HTTP response (usually 400 or 500).

type HTTPFormEnforcer added in v0.6.0

type HTTPFormEnforcer struct {
	ParameterName string
}

HTTPFormEnforcer enforces a label value extracted from the HTTP form and query parameters.

func (HTTPFormEnforcer) ExtractLabel added in v0.6.0

func (hff HTTPFormEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler

ExtractLabel implements the ExtractLabeler interface.

type HTTPHeaderEnforcer added in v0.6.0

type HTTPHeaderEnforcer struct {
	Name            string
	ParseListSyntax bool
}

HTTPHeaderEnforcer enforces a label value extracted from the HTTP headers.

func (HTTPHeaderEnforcer) ExtractLabel added in v0.6.0

func (hhe HTTPHeaderEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler

ExtractLabel implements the ExtractLabeler interface.

type Option added in v0.3.0

type Option interface {
	// contains filtered or unexported methods
}

func WithActiveAlerts added in v0.11.0

func WithActiveAlerts() Option

WithActiveAlerts causes the proxy to return rules with active alerts.

func WithEnabledLabelsAPI added in v0.3.0