roxy

package module
v0.0.0-...-3122353 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: BSD-2-Clause-Views Imports: 6 Imported by: 0

Documentation

Overview

Package roxy is a simple web proxy that can proxy by host or pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Director

type Director func(req *http.Request)

Type Director receives an http.Request that will be used as a proxy. It updates it before being passed to the proxied handler.

func Directors

func Directors(directors ...Director) Director

Type Directors chains all of the given directors into a single director.

func ToHost

func ToHost(host string) Director

ToHost returns a directory that proxies to the given host.

func ToPort

func ToPort(port int) Director

ToPort returns a director that proxies to the given port.

func ToPorts

func ToPorts(httpPort, httpsPort int) Director

ToPorts returns a director that proxies to the given httpPort, when the incoming request is non-TLS, and to the httpsPort, when the incoming request is TLS.

func ToScheme

func ToScheme(scheme string) Director

ToHost returns a directory that proxies to the given scheme.

type Proxy

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

Type Proxy implements an http.Handler that proxies http requests

func New

func New() *Proxy

New returns a new proxy.

func (*Proxy) ClearHosts

func (p *Proxy) ClearHosts()

ClearHosts clears out all of the directors currently registered.

func (*Proxy) ClearPatterns

func (p *Proxy) ClearPatterns()

ClearPatterns clears out all handlers currently registered.

func (*Proxy) ForHost

func (p *Proxy) ForHost(host string, d Director) *httputil.ReverseProxy

ForHost registers the director for the given host.

func (*Proxy) ForPattern

func (p *Proxy) ForPattern(pattern string, d Director) *httputil.ReverseProxy

ForPattern registers the pattern for the given pattern.

func (*Proxy) Handle

func (p *Proxy) Handle(pattern string, fn http.Handler)

Handle performs the same functionality as http.Handle

func (*Proxy) HandleFunc

func (p *Proxy) HandleFunc(pattern string, fn func(http.ResponseWriter, *http.Request))

HandleFunc performs the same functionality as http.HandlerFunc

func (*Proxy) RemoveHost

func (p *Proxy) RemoveHost(host string)

RemoveHost removes the director for the given host.

func (*Proxy) RemovePattern

func (p *Proxy) RemovePattern(pattern string)

RemovePattern removes the handler registerd under the given pattern.

func (Proxy) ServeHTTP

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

http.Handler implementation

Jump to

Keyboard shortcuts

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