proxy

package
v0.0.0-...-cefa5c2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package proxy implements an intercepting proxy

Index

Constants

This section is empty.

Variables

View Source
var (
	// VersionRegex matches a version of the form v123.456
	VersionRegex = regexp.MustCompile(`^/v\d\.\d+\b`)

	// ErrForbidden is returned for forbidden resources
	ErrForbidden = errors.New("error: access to resource denied")
)

Functions

func ErrorHandler

func ErrorHandler(msg string, code int) http.Handler

func JSONHandler

func JSONHandler(data interface{}) http.Handler

JSONHandler implements a JSON response handler

func Match

func Match(req *http.Request, method string, pattern string) bool

func WriteError

func WriteError(w http.ResponseWriter, msg string, code int)

Types

type Interceptor

type Interceptor interface {
	Intercept(req *http.Request, upstream http.Handler) http.Handler
}

Interceptor returns an http.Handler that either passes through to an upstream handler or imposes some logic of it's own on the request.

type InterceptorFunc

type InterceptorFunc func(req *http.Request, upstream http.Handler) http.Handler

func (InterceptorFunc) Direct

func (i InterceptorFunc) Direct(req *http.Request, upstream http.Handler) http.Handler

type Proxy

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

Proxy ...

func NewProxy

func NewProxy(dockerURL string, interceptor Interceptor) (*Proxy, error)

NewProxy ...

func (*Proxy) ServeHTTP

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

Handler ...

Jump to

Keyboard shortcuts

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