config

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentRuleSetVersion = "1alpha4"

Variables

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"    validate:"required"` //nolint:tagalign
	URLRewriter *URLRewriter `json:"rewrite" yaml:"rewrite" validate:"omitnil"`  //nolint:tagalign
}

func (*Backend) CreateURL

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

func (*Backend) DeepCopyInto

func (b *Backend) DeepCopyInto(out *Backend)

type EncodedSlashesHandling

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

type HostMatcher

type HostMatcher struct {
	Value string `json:"value" yaml:"value" validate:"required"`                        //nolint:tagalign
	Type  string `json:"type"  yaml:"type"  validate:"required,oneof=exact glob regex"` //nolint:tagalign
}

type Matcher

type Matcher struct {
	Routes              []Route       `json:"routes"               yaml:"routes"               validate:"required,dive"`              //nolint:lll,tagalign
	BacktrackingEnabled *bool         `json:"backtracking_enabled" yaml:"backtracking_enabled"`                                       //nolint:lll,tagalign
	Scheme              string        `json:"scheme"               yaml:"scheme"               validate:"omitempty,oneof=http https"` //nolint:lll,tagalign
	Methods             []string      `json:"methods"              yaml:"methods"              validate:"omitempty,dive,required"`    //nolint:lll,tagalign
	Hosts               []HostMatcher `json:"hosts"                yaml:"hosts"                validate:"omitempty,dive,required"`    //nolint:lll,tagalign
}

func (*Matcher) DeepCopyInto

func (m *Matcher) DeepCopyInto(out *Matcher)

type MetaData

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

type ParameterMatcher

type ParameterMatcher struct {
	Name  string `json:"name"  yaml:"name"  validate:"required,ne=*"`                   //nolint:tagalign
	Value string `json:"value" yaml:"value" validate:"required"`                        //nolint:tagalign
	Type  string `json:"type"  yaml:"type"  validate:"required,oneof=exact glob regex"` //nolint:tagalign
}

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 Route

type Route struct {
	Path       string             `json:"path"        yaml:"path"        validate:"required"`                //nolint:lll,tagalign
	PathParams []ParameterMatcher `json:"path_params" yaml:"path_params" validate:"omitempty,dive,required"` //nolint:lll,tagalign
}

func (*Route) DeepCopyInto

func (r *Route) DeepCopyInto(out *Route)

type Rule

type Rule struct {
	ID                     string                   `json:"id"                    yaml:"id"                    validate:"required"`                         //nolint:lll,tagalign
	EncodedSlashesHandling EncodedSlashesHandling   `json:"allow_encoded_slashes" yaml:"allow_encoded_slashes" validate:"omitempty,oneof=off on no_decode"` //nolint:lll,tagalign
	Matcher                Matcher                  `json:"match"                 yaml:"match"                 validate:"required"`                         //nolint:lll,tagalign
	Backend                *Backend                 `json:"forward_to"            yaml:"forward_to"            validate:"omitnil"`                          //nolint:lll,tagalign
	Execute                []config.MechanismConfig `json:"execute"               yaml:"execute"               validate:"gt=0,dive,required"`               //nolint:lll,tagalign
	ErrorHandler           []config.MechanismConfig `json:"on_error"              yaml:"on_error"`
}

func (*Rule) DeepCopy

func (r *Rule) DeepCopy() *Rule

func (*Rule) DeepCopyInto

func (r *Rule) DeepCopyInto(out *Rule)

func (*Rule) Hash

func (r *Rule) Hash() ([]byte, error)

type RuleSet

type RuleSet struct {
	MetaData

	Version string `json:"version" yaml:"version" validate:"required"` //nolint:tagalign
	Name    string `json:"name"    yaml:"name"`
	Rules   []Rule `json:"rules"   yaml:"rules"   validate:"gt=0,dive,required"` //nolint:tagalign
}

func ParseRules

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