Documentation ¶
Index ¶
- Constants
- type HeaderLookup
- func (hl *HeaderLookup) Close()
- func (hl *HeaderLookup) DefaultSpec() interface{}
- func (hl *HeaderLookup) Description() string
- func (hl *HeaderLookup) Handle(ctx httpcontext.HTTPContext) string
- func (hl *HeaderLookup) Inherit(filterSpec *httppipeline.FilterSpec, previousGeneration httppipeline.Filter)
- func (hl *HeaderLookup) Init(filterSpec *httppipeline.FilterSpec)
- func (hl *HeaderLookup) Kind() string
- func (hl *HeaderLookup) Results() []string
- 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) DefaultSpec ¶
func (hl *HeaderLookup) DefaultSpec() interface{}
DefaultSpec returns the default spec of HeaderLookup.
func (*HeaderLookup) Description ¶
func (hl *HeaderLookup) Description() string
Description returns the description of HeaderLookup.
func (*HeaderLookup) Handle ¶
func (hl *HeaderLookup) Handle(ctx httpcontext.HTTPContext) string
Handle retrieves header values and sets request headers.
func (*HeaderLookup) Inherit ¶
func (hl *HeaderLookup) Inherit(filterSpec *httppipeline.FilterSpec, previousGeneration httppipeline.Filter)
Inherit inherits previous generation of HeaderLookup.
func (*HeaderLookup) Init ¶
func (hl *HeaderLookup) Init(filterSpec *httppipeline.FilterSpec)
Init initializes HeaderLookup.
func (*HeaderLookup) Kind ¶
func (hl *HeaderLookup) Kind() string
Kind returns the kind of HeaderLookup.
func (*HeaderLookup) Results ¶
func (hl *HeaderLookup) Results() []string
Results returns the results of HeaderLookup.
type HeaderSetterSpec ¶
type HeaderSetterSpec struct { EtcdKey string `yaml:"etcdKey,omitempty" jsonschema:"omitempty"` HeaderKey string `yaml:"headerKey,omitempty" jsonschema:"omitempty"` }
HeaderSetterSpec defines etcd source key and request destination header.
type Spec ¶
type Spec struct { HeaderKey string `yaml:"headerKey" jsonschema:"required"` EtcdPrefix string `yaml:"etcdPrefix" jsonschema:"required"` PathRegExp string `yaml:"pathRegExp" jsonschema:"omitempty"` HeaderSetters []*HeaderSetterSpec `yaml:"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.