Documentation
¶
Index ¶
- Constants
- Variables
- func ParseAliases(in string) (names []string, err error)
- func ReverseHostPort(s string) string
- func SetMetricsProvider(p metrics.Provider)
- func SetTable(t Table)
- type Cmd
- type GlobCache
- type Route
- type RouteDef
- type Routes
- type Table
- type Target
- func (t *Target) AccessDeniedHTTP(r *http.Request) bool
- func (t *Target) AccessDeniedTCP(c net.Conn) bool
- func (t *Target) Authorized(r *http.Request, w http.ResponseWriter, authSchemes map[string]auth.AuthScheme) bool
- func (t *Target) BuildRedirectURL(requestURL *url.URL)
- func (t *Target) ProcessAccessRules() error
Constants ¶
const Commands = `` /* 1974-byte string literal not displayed */
Variables ¶
var Matcher = map[string]matcher{
"prefix": prefixMatcher,
"glob": globMatcher,
"iprefix": iPrefixMatcher,
}
Matcher contains the available matcher functions. Update config/load.go#load after updating.
var Picker = map[string]picker{
"rnd": rndPicker,
"rr": rrPicker,
}
Picker contains the available picker functions. Update config/load.go#load after updating.
Functions ¶
func ParseAliases ¶ added in v1.5.11
ParseAliases scans a set of route commands for the "register" option and returns a list of services which should be registered by the backend.
func ReverseHostPort ¶ added in v1.5.14
ReverseHostPort returns its argument string reversed rune-wise left to right. If s includes a port, only the host part is reversed.
func SetMetricsProvider ¶ added in v1.6.0
Types ¶
type GlobCache ¶ added in v1.5.14
type GlobCache struct {
// contains filtered or unexported fields
}
GlobCache implements an LRU cache for compiled glob patterns.
func NewGlobCache ¶ added in v1.5.14
type Route ¶ added in v1.0.6
type Route struct {
// Glob represents compiled pattern.
Glob glob.Glob
// Host contains the host of the route.
// not used for routing but for config generation
// Table has a map with the host as key
// for faster lookup and smaller search space.
Host string
// Path is the path prefix from a request uri
Path string
// Targets contains the list of URLs
Targets []*Target
// contains filtered or unexported fields
}
Route maps a path prefix to one or more target URLs. routes can have a weight value which describes the amount of traffic this route should get. You can specify that a route should get a fixed percentage of the traffic independent of how many instances are running.
type RouteDef ¶ added in v1.3.6
type Routes ¶ added in v1.0.6
type Routes []*Route
Routes stores a list of routes usually for a single host.
type Table ¶
Table contains a set of routes grouped by host. The host routes are sorted from most to least specific by sorting the routes in reverse order by path.
func GetTable ¶
func GetTable() Table
GetTable returns the active routing table. The function is safe to be called from multiple goroutines and the value is never nil.
func NewTableCustom ¶ added in v1.5.14
func (Table) Lookup ¶ added in v1.0.5
func (t Table) Lookup(req *http.Request, trace string, pick picker, match matcher, globCache *GlobCache, globDisabled bool) (target *Target)
Lookup finds a target url based on the current matcher and picker or nil if there is none. It first checks the routes for the host and if none matches then it falls back to generic routes without a host. This is useful for a catch-all '/' rule.
func (Table) LookupHost ¶ added in v1.3.1
type Target ¶ added in v1.0.5
type Target struct {
// Histogram measures throughput and latency of this target
Timer gkm.Histogram
// Counters for rx and tx
RxCounter gkm.Counter
TxCounter gkm.Counter
// Opts is the raw options for the target.
Opts map[string]string
// URL is the endpoint the service instance listens on
URL *url.URL
// RedirectURL is the redirect target based on the request.
// This is cached here to prevent multiple generations per request.
RedirectURL *url.URL
// Transport allows for different types of transports
Transport *http.Transport
// Service is the name of the service the targetURL points to
Service string
// StripPath will be removed from the front of the outgoing
// request path
StripPath string
// PrependPath will be added to the front of the outgoing
// request path (after StripPath has been removed)
PrependPath string
// Host signifies what the proxy will set the Host header to.
// The proxy does not modify the Host header by default.
// When Host is set to 'dst' the proxy will use the host name
// of the target host for the outgoing request.
Host string
// name of the auth handler for this target
AuthScheme string
// Tags are the list of tags for this target
Tags []string
// RedirectCode is the HTTP status code used for redirects.
// When set to a value > 0 the client is redirected to the target url.
RedirectCode int
// FixedWeight is the weight assigned to this target.
// If the value is 0 the targets weight is dynamic.
FixedWeight float64
// Weight is the actual weight for this service in percent.
Weight float64
// TLSSkipVerify disables certificate validation for upstream
// TLS connections.
TLSSkipVerify bool
// ProxyProto enables PROXY Protocol on upstream connection
ProxyProto bool
// contains filtered or unexported fields
}
func (*Target) AccessDeniedHTTP ¶ added in v1.5.11
AccessDeniedHTTP checks rules on the target for HTTP proxy routes.
func (*Target) AccessDeniedTCP ¶ added in v1.5.11
AccessDeniedTCP checks rules on the target for TCP proxy routes.
func (*Target) Authorized ¶ added in v1.5.11
func (t *Target) Authorized(r *http.Request, w http.ResponseWriter, authSchemes map[string]auth.AuthScheme) bool
func (*Target) BuildRedirectURL ¶ added in v1.5.11
func (*Target) ProcessAccessRules ¶ added in v1.5.11
ProcessAccessRules processes access rules from options specified on the target route