Documentation ¶
Index ¶
- func MustLabelValue(ctx context.Context) string
- func MustLabelValues(ctx context.Context) []string
- func NewRoutes(upstream *url.URL, label string, extractLabeler ExtractLabeler, opts ...Option) (*routes, error)
- func WithLabelValues(ctx context.Context, labels []string) context.Context
- type Enforcer
- type ExtractLabeler
- type HTTPFormEnforcer
- type HTTPHeaderEnforcer
- type IllegalLabelMatcherError
- type Option
- type StaticLabelEnforcer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustLabelValue ¶ added in v0.6.0
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
MustLabelValues returns labels (previously stored using WithLabelValue()) from the given context. It will panic if no label is found or the value is empty.
Types ¶
type Enforcer ¶ added in v0.2.0
type Enforcer struct {
// contains filtered or unexported fields
}
func NewEnforcer ¶ added in v0.2.0
func (Enforcer) EnforceMatchers ¶ added in v0.4.0
EnforceMatchers appends the configured label matcher if not present. If the label matcher that is to be injected is present (by labelname) but different (either by match type or value) the behavior depends on the errorOnReplace variable and the enforced matcher(s): * if errorOnReplace is true, an error is returned, * if errorOnReplace is false and the label matcher type is '=', the existing matcher is silently replaced. * otherwise the existing matcher is preserved.
func (Enforcer) EnforceNode ¶ added in v0.2.0
EnforceNode walks the given node recursively and enforces the given label enforcer on it.
Whenever a parser.MatrixSelector or parser.VectorSelector AST node is found, their label enforcer is being potentially modified. If a node's label matcher has the same name as a label matcher of the given enforcer, then it will be replaced.
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
}
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 IllegalLabelMatcherError ¶ added in v0.4.0
type IllegalLabelMatcherError struct {
// contains filtered or unexported fields
}
func (IllegalLabelMatcherError) Error ¶ added in v0.4.0
func (e IllegalLabelMatcherError) Error() string
type Option ¶ added in v0.3.0
type Option interface {
// contains filtered or unexported methods
}
func WithEnabledLabelsAPI ¶ added in v0.3.0
func WithEnabledLabelsAPI() Option
WithEnabledLabelsAPI enables proxying to labels API. If false, "501 Not implemented" will be return for those.
func WithErrorOnReplace ¶ added in v0.4.0
func WithErrorOnReplace() Option
WithErrorOnReplace causes the proxy to return 400 if a label matcher we want to inject is present in the query already and matches something different
func WithPassthroughPaths ¶ added in v0.3.0
WithPassthroughPaths configures routes to register given paths as passthrough handlers for all HTTP methods. that, if requested, will be forwarded without enforcing label. Use with care. NOTE: Passthrough "all" paths like "/" or "" and regex are not allowed.
func WithPrometheusRegistry ¶ added in v0.6.0
func WithPrometheusRegistry(reg prometheus.Registerer) Option
WithPrometheusRegistry configures the proxy to use the given registerer.
func WithRegexMatch ¶ added in v0.8.0
func WithRegexMatch() Option
WithRegexMatch causes the proxy to handle tenant name as regexp
type StaticLabelEnforcer ¶ added in v0.6.0
type StaticLabelEnforcer []string
StaticLabelEnforcer enforces a static label value.
func (StaticLabelEnforcer) ExtractLabel ¶ added in v0.6.0
func (sle StaticLabelEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler
ExtractLabel implements the ExtractLabeler interface.