headerlookup

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package headerlookup implements a filter that enriches request headers per request, looking up values from etcd.

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) 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) Init

func (hl *HeaderLookup) Init()

Init initializes 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

func (*HeaderLookup) Status

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

Status returns status.

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.

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