config

package
v0.14.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentRuleSetVersion = "1alpha3"

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 Backend

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

func (*Backend) CreateURL

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

func (*Backend) DeepCopyInto

func (f *Backend) DeepCopyInto(out *Backend)

type EncodedSlashesHandling

type EncodedSlashesHandling string
const (
	EncodedSlashesOff      EncodedSlashesHandling = "off"
	EncodedSlashesOn       EncodedSlashesHandling = "on"
	EncodedSlashesNoDecode EncodedSlashesHandling = "no_decode"
)

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"`
	EncodedSlashesHandling EncodedSlashesHandling   `json:"allow_encoded_slashes" yaml:"allow_encoded_slashes" validate:"omitempty,oneof=off on no_decode"` //nolint:lll,tagalign
	RuleMatcher            Matcher                  `json:"match"                 yaml:"match"`
	Backend                *Backend                 `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"   validate:"dive" yaml:"rules"`
}

func ParseRules

func ParseRules(contentType string, reader io.Reader, envUsageEnabled bool) (*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)

Jump to

Keyboard shortcuts

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