headerlookup

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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) Close

func (hl *HeaderLookup) Close()

Close closes HeaderLookup.

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.

func (*HeaderLookup) Status

func (hl *HeaderLookup) Status() interface{}

Status returns status.

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.

func (Spec) Validate

func (spec Spec) Validate() error

Validate validates spec.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL