proxy

package
v0.0.729 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: Apache-2.0 Imports: 13 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(hostMapper HostMapper, opts ...Options) http.Handler

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

func ReplaceCookieDomainAndSecure added in v0.0.309

func ReplaceCookieDomainAndSecure(resp *http.Response, original, replacement string, secure bool)

ReplaceCookieDomainAndSecure replaces the domain of all matching Set-Cookie headers in the response.

Types

type HostConfig

type HostConfig struct {
	// CorsEnabled is a flag to enable or disable CORS
	// Default: false
	CorsEnabled bool
	// CorsOptions allows to configure CORS
	// If left empty, no CORS headers will be set even when CorsEnabled is true
	CorsOptions *cors.Options
	// CookieDomain is the host under which cookies are set.
	// If left empty, no cookie domain will be set
	CookieDomain string
	// UpstreamHost is the next upstream host the proxy will pass the request to.
	// e.g. fluffy-bear-afiu23iaysd.oryapis.com
	UpstreamHost string
	// UpstreamScheme is the protocol used by the upstream service.
	UpstreamScheme string
	// TargetHost is the final target of the request. Should be the same as UpstreamHost
	// if the request is directly passed to the target service.
	TargetHost string
	// TargetScheme is the final target's scheme
	// (i.e. the scheme the target thinks it is running under)
	TargetScheme string
	// PathPrefix is a prefix that is prepended on the original host,
	// but removed before forwarding.
	PathPrefix string
	// TrustForwardedHosts is a flag that indicates whether the proxy should trust the
	// X-Forwarded-* headers or not.
	TrustForwardedHeaders bool

	// ForceOriginalSchemeHTTP forces the original scheme to be https if enabled.
	ForceOriginalSchemeHTTPS bool
	// contains filtered or unexported fields
}

type HostMapper added in v0.0.309

type HostMapper func(ctx context.Context, r *http.Request) (context.Context, *HostConfig, error)

type Options

type Options func(*options)

func WithErrorHandler added in v0.0.450

func WithErrorHandler(eh func(w http.ResponseWriter, r *http.Request, err error)) 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 *httputil.ProxyRequest, config *HostConfig, body []byte) ([]byte, error)

type RespMiddleware

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

Jump to

Keyboard shortcuts

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