route

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2015 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetPickerStrategy

func SetPickerStrategy(s string) error

SetPickerStrategy sets the picker function for the proxy.

func SetTable

func SetTable(t Table)

func Shutdown

func Shutdown()

func ShuttingDown

func ShuttingDown() bool

Types

type Proxy

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

Proxy is a dynamic reverse proxy.

func NewProxy

func NewProxy(tr http.RoundTripper, clientIPHeader, tlsHeader, tlsHeaderValue string) *Proxy

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Table

type Table map[string]routes

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

func Parse

func Parse(r io.Reader) (Table, error)

Parse loads a routing table from a set of route commands.

The commands are parsed in order and order matters. Deleting a route that has not been created yet yields a different result than the other way around.

Route commands can have the following form:

route add service host/path targetURL
- Add a new route for host/path to targetURL

route del service
- Remove all routes for service

route del service host/path
- Remove all routes for host/path for this service only

route del service host/path targetURL
 - Remove only this route

func ParseFile

func ParseFile(path string) (Table, error)

ParseFile loads a routing table from a file.

func ParseString

func ParseString(s string) (Table, error)

ParseString loads a routing table from a string.

func (Table) AddRoute

func (t Table) AddRoute(service, prefix, target string, weight float64, tags []string) error

AddRoute adds a new route prefix -> target for the given service.

func (Table) AddRouteWeight

func (t Table) AddRouteWeight(service, prefix string, weight float64, tags []string) error

func (Table) Config

func (t Table) Config(addWeight bool) []string

func (Table) DelRoute

func (t Table) DelRoute(service, prefix, target string) error

DelRoute removes one or more routes depending on the arguments. If service, prefix and target are provided then only this route is removed. Are only service and prefix provided then all routes for this service and prefix are removed. This removes all active instances of the service from the route. If only the service is provided then all routes for this service are removed. The service will no longer receive traffic.

func (Table) String

func (t Table) String() string

String returns the routing table as config file which can be read by Parse() again.

Jump to

Keyboard shortcuts

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