config

package
v0.10.0-alpha Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const CurrentRuleSetVersion = "1alpha2"

Variables

View Source
var (
	ErrURLMissing          = errors.New("url property not present")
	ErrURLType             = errors.New("bad url type")
	ErrStrategyType        = errors.New("bad strategy type")
	ErrUnsupportedStrategy = errors.New("unsupported strategy")
)
View Source
var ErrEmptyRuleSet = errors.New("empty rule set")

Functions

func DecodeConfig

func DecodeConfig(input any, output any) error

Types

type Matcher

type Matcher struct {
	URL      string `json:"url" yaml:"url"`
	Strategy string `json:"strategy" yaml:"strategy"`
}

func (*Matcher) UnmarshalJSON

func (m *Matcher) UnmarshalJSON(data []byte) error

type MetaData

type MetaData struct {
	Hash    []byte    `json:"-" yaml:"-"`
	Source  string    `json:"-" yaml:"-"`
	ModTime time.Time `json:"-" yaml:"-"`
}

type PrefixAdder

type PrefixAdder string

func (PrefixAdder) AddTo

func (a PrefixAdder) AddTo(value string) string

type PrefixCutter

type PrefixCutter string

func (PrefixCutter) CutFrom

func (c PrefixCutter) CutFrom(value string) string

type QueryParamsRemover

type QueryParamsRemover []string

func (QueryParamsRemover) RemoveFrom

func (r QueryParamsRemover) RemoveFrom(value string) string

type Rule

type Rule struct {
	ID                 string                   `json:"id" yaml:"id"`
	RuleMatcher        Matcher                  `json:"match" yaml:"match"`
	UpstreamURLFactory *UpstreamURLFactory      `json:"forward_to" yaml:"forward_to"`
	Methods            []string                 `json:"methods" yaml:"methods"`
	Execute            []config.MechanismConfig `json:"execute" yaml:"execute"`
	ErrorHandler       []config.MechanismConfig `json:"on_error" yaml:"on_error"`
}

func (*Rule) DeepCopy

func (in *Rule) DeepCopy() *Rule

func (*Rule) DeepCopyInto

func (in *Rule) DeepCopyInto(out *Rule)

type RuleSet

type RuleSet struct {
	MetaData

	Version string `json:"version" yaml:"version"`
	Name    string `json:"name" yaml:"name"`
	Rules   []Rule `json:"rules" yaml:"rules"`
}

func ParseRules

func ParseRules(contentType string, reader io.Reader) (*RuleSet, error)

func (RuleSet) VerifyPathPrefix

func (rs RuleSet) VerifyPathPrefix(prefix string) error

type URLRewriter

type URLRewriter struct {
	Scheme              string             `json:"scheme" yaml:"scheme"`
	PathPrefixToCut     PrefixCutter       `json:"strip_path_prefix" yaml:"strip_path_prefix"`
	PathPrefixToAdd     PrefixAdder        `json:"add_path_prefix" yaml:"add_path_prefix"`
	QueryParamsToRemove QueryParamsRemover `json:"strip_query_parameters" yaml:"strip_query_parameters"`
}

func (*URLRewriter) Rewrite

func (r *URLRewriter) Rewrite(value *url.URL)

type UpstreamURLFactory

type UpstreamURLFactory struct {
	Host        string       `json:"host" yaml:"host"`
	URLRewriter *URLRewriter `json:"rewrite" yaml:"rewrite"`
}

func (*UpstreamURLFactory) CreateURL

func (f *UpstreamURLFactory) CreateURL(value *url.URL) *url.URL

func (*UpstreamURLFactory) DeepCopyInto

func (f *UpstreamURLFactory) DeepCopyInto(out *UpstreamURLFactory)

Jump to

Keyboard shortcuts

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