Documentation
¶
Overview ¶
Package headerlookup implements a filter that enriches request headers per request, looking up values from etcd.
Index ¶
- Constants
- type HeaderLookup
- func (hl *HeaderLookup) Close()
- func (hl *HeaderLookup) Handle(ctx *context.Context) string
- func (hl *HeaderLookup) Inherit(previousGeneration filters.Filter)
- func (hl *HeaderLookup) Init()
- func (hl *HeaderLookup) Kind() *filters.Kind
- func (hl *HeaderLookup) Name() string
- func (hl *HeaderLookup) Spec() filters.Spec
- func (hl *HeaderLookup) Status() interface{}
- type HeaderSetterSpec
- type Spec
Constants ¶
const (
// Kind is the kind of HeaderLookup.
Kind = "HeaderLookup"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HeaderLookup ¶
type HeaderLookup struct {
// contains filtered or unexported fields
}
HeaderLookup retrieves values from etcd to headers.
func (*HeaderLookup) Handle ¶
func (hl *HeaderLookup) Handle(ctx *context.Context) string
Handle retrieves header values and sets request headers.
func (*HeaderLookup) Inherit ¶
func (hl *HeaderLookup) Inherit(previousGeneration filters.Filter)
Inherit inherits previous generation of HeaderLookup.
func (*HeaderLookup) Kind ¶
func (hl *HeaderLookup) Kind() *filters.Kind
Kind returns the kind of HeaderLookup.
func (*HeaderLookup) Name ¶
func (hl *HeaderLookup) Name() string
Name returns the name of the HeaderLookup filter instance.
func (*HeaderLookup) Spec ¶
func (hl *HeaderLookup) Spec() filters.Spec
Spec returns the spec used by the HeaderLookup
type HeaderSetterSpec ¶
type HeaderSetterSpec struct { EtcdKey string `json:"etcdKey,omitempty"` HeaderKey string `json:"headerKey,omitempty"` }
HeaderSetterSpec defines etcd source key and request destination header.
type Spec ¶
type Spec struct { filters.BaseSpec `json:",inline"` HeaderKey string `json:"headerKey" jsonschema:"required"` EtcdPrefix string `json:"etcdPrefix" jsonschema:"required"` PathRegExp string `json:"pathRegExp,omitempty"` HeaderSetters []*HeaderSetterSpec `json:"headerSetters" jsonschema:"required"` }
Spec defines header key and etcd prefix that form etcd key like /custom-data/{etcdPrefix}/{headerKey's value}. This /custom-data/{etcdPrefix}/{headerKey's value} is retrieved from etcd and HeaderSetters extract keys from the from the retrieved etcd item. When PathRegExp is defined, PathRegExp is used with `regexp.FindStringSubmatch` to identify a group from path. The first captured group is appended to the etcd key in following format: /custom-data/{etcdPrefix}/{headerKey's value}-{regex group} . For example, for path "/api/bananas/33" and pathRegExp: "^/api/([a-z]+)/[0-9]*", the group "bananas" is extracted and etcd key is /custom-data/{etcdPrefix}/{headerKey's value}-bananas.