proxy

package
v0.0.306 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(hostMapper func(ctx context.Context, host string) (*HostConfig, error), opts ...Options) http.Handler

New creates a new Proxy A Proxy sets up a middleware with custom request and response modification handlers

Types

type HostConfig

type HostConfig struct {
	// CookieDomain the host under which the cookie should be set
	// e.g. example.com
	// If left empty, will ask the browser to use the browser address bar's host (default HTTP Cookie behavior)
	CookieDomain string
	// UpstreamHost the target upstream host the proxy will pass the connection to
	// e.g. fluffy-bear-afiu23iaysd.oryapis.com
	UpstreamHost string
	// PathPrefix is a prefix that is prepended on the original host,
	// but removed on the upstream.
	PathPrefix string
	// UpstreamProtocol is the protocol used by the upstream.
	UpstreamProtocol string
	// contains filtered or unexported fields
}

type Options

type Options func(*options)

func WithOnError

func WithOnError(onReqErr func(*http.Request, error), onResErr func(*http.Response, error) error) Options

func WithReqMiddleware

func WithReqMiddleware(middlewares ...ReqMiddleware) Options

func WithRespMiddleware

func WithRespMiddleware(middlewares ...RespMiddleware) Options

func WithTransport

func WithTransport(t http.RoundTripper) Options

type ReqMiddleware

type ReqMiddleware func(req *http.Request, body []byte) ([]byte, error)

type RespMiddleware

type RespMiddleware func(resp *http.Response, body []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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