atc

package
v3.1.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	FieldTypeInt = iota
	FieldTypeString
	FieldTypeSingleIP
	FieldTypeIPCIDR
)

Variables

View Source
var (
	ErrTypeNotMatch    = errors.New("type does not match on sides of predicate")
	ErrOperatorInvalid = errors.New("operator is not valid for the types of sides of predicate")
)

Functions

func ApplyExpression

func ApplyExpression(r *kong.Route, m Matcher, priority uint64)

ApplyExpression sets a Matcher as a Kong route's expression and assigns the route the given priority.

Types

type AndMatcher

type AndMatcher struct {
	// contains filtered or unexported fields
}

func And

func And(matchers ...Matcher) *AndMatcher

And constructs an AndMatcher from a list of Matchers. If any of the given Matchers is empty, And skips adding it.

func (*AndMatcher) And

func (m *AndMatcher) And(matcher Matcher) *AndMatcher

And appends an additional Matcher to an existing AndMatcher. If the given Matcher is empty, it returns the original AndMatcher.

func (*AndMatcher) Expression

func (m *AndMatcher) Expression() string

func (*AndMatcher) IsEmpty

func (m *AndMatcher) IsEmpty() bool

type BinaryOperator

type BinaryOperator string

BinaryOperator is an operator that accepts two arguments within a predicate expression.

const (
	OpEqual        BinaryOperator = "=="
	OpNotEqual     BinaryOperator = "!="
	OpRegexMatch   BinaryOperator = "~"
	OpPrefixMatch  BinaryOperator = "^="
	OpSuffixMatch  BinaryOperator = "=^"
	OpIn           BinaryOperator = "in"
	OpNotIn        BinaryOperator = "not in"
	OpContains     BinaryOperator = "contains"
	OpLessThan     BinaryOperator = "<"
	OpLessEqual    BinaryOperator = "<="
	OpGreaterThan  BinaryOperator = ">"
	OpGreaterEqual BinaryOperator = ">="
)

type FieldType

type FieldType int

type HTTPHeaderField

type HTTPHeaderField struct {
	HeaderName string
}

HTTPHeaderField extracts the value of an HTTP header from the request.

func (HTTPHeaderField) FieldType

func (f HTTPHeaderField) FieldType() FieldType

func (HTTPHeaderField) String

func (f HTTPHeaderField) String() string

type HTTPQueryField

type HTTPQueryField struct {
	QueryParamName string
}

HTTPQueryField extracts the value of an HTTP query parameter from the query string of the request.

func (HTTPQueryField) FieldType

func (f HTTPQueryField) FieldType() FieldType

func (HTTPQueryField) String

func (f HTTPQueryField) String() string

type IntField

type IntField string

IntField is defined for fields with constant name and having integer type. The inner string value is the name of the field.

const (
	FieldNetDstPort IntField = "net.dst.port"
)

func (IntField) FieldType

func (f IntField) FieldType() FieldType

func (IntField) String

func (f IntField) String() string

type IntLiteral

type IntLiteral int

IntLiteral is an integer Literal.

func (IntLiteral) String

func (l IntLiteral) String() string

func (IntLiteral) Type

func (l IntLiteral) Type() LiteralType

type LHS

type LHS interface {
	// FieldType returns the FieldType iota indicating the LHS type.
	FieldType() FieldType

	// String returns a string representation of the LHS.
	String() string
}

LHS is the left hand side (the field) of a predicate expression.

type Literal

type Literal interface {
	// Type returns the LiteralType iota indicating the Literal type.
	Type() LiteralType

	// String returns a string representation of the Literal.
	String() string
}

Literal is the right hand side (the value) of a predicate expression.

type LiteralType

type LiteralType int
const (
	LiteralTypeInt LiteralType = iota
	LiteralTypeString
	// LiteralTypeIP is a type that represents a literal of a single IP address or an IP CIDR.
	//
	// TODO: define subtypes of IP literals(IPv4/IPv6;single IP/IP CIDR).
	LiteralTypeIP
)

type Matcher

type Matcher interface {
	// Expression returns a string representation of the Matcher that could be a valid Kong route expression.
	Expression() string

	// IsEmpty() returns a boolean indicating if the Matcher is empty. It is true if the Matcher is an empty struct,
	// if the Matcher has zero subMatchers, or if a single-predicate Matcher has no value.
	IsEmpty() bool
}

Matcher is a sub-expression within a Kong router expression. It can be a single predicate expression, a group of predicates joined by logical operators, or a recursive combination of either of the previous components.

type OrMatcher

type OrMatcher struct {
	// contains filtered or unexported fields
}

OrMatcher is a group of Matchers joined by logical ORs.

func Or

func Or(matchers ...Matcher) *OrMatcher

Or constructs an OrMatcher from a list of Matchers. If any of the given Matchers is empty, Or skips adding it.

func (*OrMatcher) Expression

func (m *OrMatcher) Expression() string

func (*OrMatcher) IsEmpty

func (m *OrMatcher) IsEmpty() bool

func (*OrMatcher) Or

func (m *OrMatcher) Or(matcher Matcher) *OrMatcher

Or appends an additional Matcher to an existing OrMatcher. If the given Matcher is empty, it returns the original OrMatcher.

type Predicate

type Predicate struct {
	// contains filtered or unexported fields
}

Predicate is an expression consisting of two arguments and a comparison operator. Kong's expression router evaluates these to true or false.

func NewPrediacteHTTPHost

func NewPrediacteHTTPHost(op BinaryOperator, value string) Predicate

func NewPredicate

func NewPredicate(lhs LHS, op BinaryOperator, rhs Literal) (Predicate, error)

NewPredicate generates a single predicate.

func NewPredicateHTTPHeader

func NewPredicateHTTPHeader(key string, op BinaryOperator, value string) Predicate

func NewPredicateHTTPMethod

func NewPredicateHTTPMethod(op BinaryOperator, value string) Predicate

func NewPredicateHTTPPath

func NewPredicateHTTPPath(op BinaryOperator, value string) Predicate

func NewPredicateHTTPQuery

func NewPredicateHTTPQuery(key string, op BinaryOperator, value string) Predicate

func NewPredicateNetProtocol

func NewPredicateNetProtocol(op BinaryOperator, value string) Predicate

func NewPredicateTLSSNI

func NewPredicateTLSSNI(op BinaryOperator, value string) Predicate

func (Predicate) Expression

func (p Predicate) Expression() string

Expression returns a string representation of a Predicate.

func (Predicate) IsEmpty

func (p Predicate) IsEmpty() bool

IsEmpty returns true if a Predicate has no value to compare against.

type StringField

type StringField string

StringField is defined for fields with constant name and having string type. The inner string value is the name of the field.

const (
	FieldNetProtocol StringField = "net.protocol"
	FieldTLSSNI      StringField = "tls.sni"
	FieldHTTPMethod  StringField = "http.method"
	FieldHTTPHost    StringField = "http.host"
	FieldHTTPPath    StringField = "http.path"
)

func (StringField) FieldType

func (f StringField) FieldType() FieldType

func (StringField) String

func (f StringField) String() string

type StringLiteral

type StringLiteral string

StringLiteral is a string Literal.

func (StringLiteral) String

func (l StringLiteral) String() string

func (StringLiteral) Type

func (l StringLiteral) Type() LiteralType

type TransformLower

type TransformLower struct {
	// contains filtered or unexported fields
}

TransformLower instructs Kong to transform a field (for example, http.path) to lowercase before comparing it to a value in a predicate expression. It can only be applied to the left side of a predicate expression.

func NewTransformerLower

func NewTransformerLower(inner LHS) TransformLower

func (TransformLower) FieldType

func (t TransformLower) FieldType() FieldType

func (TransformLower) String

func (t TransformLower) String() string

Jump to

Keyboard shortcuts

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