Documentation
¶
Index ¶
- func NewRoutes(upstream *url.URL, extractLabeler ExtractLabeler, opts ...Option) (*routes, error)
- func WithLabelMap(ctx context.Context, labels LabelMap) context.Context
- type Enforcer
- type ExtractLabeler
- type HTTPFormEnforcer
- type HTTPHeaderEnforcer
- type LabelMap
- type Option
- type StaticLabelEnforcer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Enforcer ¶
type Enforcer struct {
// contains filtered or unexported fields
}
func NewEnforcer ¶
func (Enforcer) EnforceMatchers ¶
EnforceMatchers appends the configured label matcher if not present. If the label matcher that is to be injected is present (by labelname) it will be preserved.
func (Enforcer) EnforceNode ¶
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 ¶
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 ¶
HTTPFormEnforcer enforces a label value extracted from the HTTP form and query parameters.
func (HTTPFormEnforcer) ExtractLabel ¶
func (hff HTTPFormEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler
ExtractLabel implements the ExtractLabeler interface.
type HTTPHeaderEnforcer ¶
HTTPHeaderEnforcer enforces a label value extracted from the HTTP headers.
func (HTTPHeaderEnforcer) ExtractLabel ¶
func (hhe HTTPHeaderEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler
ExtractLabel implements the ExtractLabeler interface.
type LabelMap ¶
func MustLabelMap ¶
MustLabelMap returns labels (previously stored using WithLabelValue()) from the given context. It will panic if no label is found or the value is empty.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithEnabledLabelsAPI ¶
func WithEnabledLabelsAPI() Option
WithEnabledLabelsAPI enables proxying to labels API. If false, "501 Not implemented" will be return for those.
func WithModifyProxyRequest ¶
WithModifyProxyRequest allows to modify the proxy request before it is sent to the upstream. can be used to add custom headers, like basic auth.
func WithPassthroughPaths ¶
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 WithPathPrefix ¶
func WithPrometheusRegistry ¶
func WithPrometheusRegistry(reg prometheus.Registerer) Option
WithPrometheusRegistry configures the proxy to use the given registerer.
type StaticLabelEnforcer ¶
StaticLabelEnforcer enforces a static label value.
func (StaticLabelEnforcer) ExtractLabel ¶
func (sle StaticLabelEnforcer) ExtractLabel(next http.HandlerFunc) http.Handler
ExtractLabel implements the ExtractLabeler interface.