pkg

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExplicitProxy

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

func NewExplicitProxy

func NewExplicitProxy(upstreamBaseURL *url.URL, requestHandler RequestHandlerI) *ExplicitProxy

if upstreamBaseURL is nil, it will be set to defaultUpstreamBaseURL

func (*ExplicitProxy) ServeHTTP

func (p *ExplicitProxy) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*ExplicitProxy) Start

func (p *ExplicitProxy) Start(localPort int, tlsConfig *types.TLSConfig) error

Start starts a HTTP server listening on localPort If tlsConfig is nil, will expect plain HTTP. This is a blocking call.

type MITMProxy

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

func NewMITMProxy

func NewMITMProxy(requestHandler RequestHandlerI) *MITMProxy

func (*MITMProxy) Start

func (p *MITMProxy) Start(localPort int, tlsConfig *types.TLSConfig) error

Start starts a HTTP proxy listening on localPort; tlsConfig cannot be nil. This is a blocking call.

type RequestHandler

type RequestHandler struct {
	// The transport used to perform proxy requests.
	// If nil, http.DefaultTransport is used.
	Transport http.RoundTripper

	// Github API requests that fail because of an exhausted token will be retried (with different tokens)
	// up to MaxGithubRetries times - defaults to defaultMaxGithubRetries if <= 0
	MaxGithubRetries int
	// contains filtered or unexported fields
}

func NewRequestHandler

func NewRequestHandler(githubURL *url.URL, tokenPool token_pools.TokenPoolStorageBackend) *RequestHandler

func (*RequestHandler) HandleGithubAPIRequest

func (h *RequestHandler) HandleGithubAPIRequest(writer http.ResponseWriter, request *http.Request)

func (*RequestHandler) HandleRequest

func (h *RequestHandler) HandleRequest(writer http.ResponseWriter, request *http.Request)

func (*RequestHandler) ProxyRequest

func (h *RequestHandler) ProxyRequest(request *http.Request) (response *http.Response, err error)

type RequestHandlerI

type RequestHandlerI interface {
	// ProxyRequest should take any request, transparently proxy any request that's not made
	// to Github, and handle auth and throttling for requests made to Github
	ProxyRequest(request *http.Request) (response *http.Response, err error)

	// Same idea as ProxyRequest, but meant to be used as a http.Handler
	HandleRequest(writer http.ResponseWriter, request *http.Request)

	// Same as HandleRequest, but blindly re-routes all incoming requests to Github's API, regardless
	// of what host they were originally meant for.
	HandleGithubAPIRequest(writer http.ResponseWriter, request *http.Request)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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