proxy

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	List(ctx *Context)
	Info(ctx *Context)
	Latest(ctx *Context)
	Mod(ctx *Context)
	Zip(ctx *Context)
}

Backend implements all the standard interfaces of GOPROXY, which is the upstream of request processing

type Config

type Config struct {
	UpstreamAddr string `valid:"url"`
	ListenAddr   string `valid:"url"`
	GoBinaryPath string
}

Config contains configuration information for the entire proxy project

type Context

type Context struct {
	*module.Path
	*gin.Context
	// contains filtered or unexported fields
}

Context is used to pass variables between processors

type Engine

type Engine struct {
	Config
	// contains filtered or unexported fields
}

Engine controls the operation of the entire Proxy

func Default

func Default() *Engine

Default is used to initialize an Engine with default settings

func New

func New(config *Config) *Engine

New is used to initialize a user-configured Engine

func (*Engine) GetBackend

func (engine *Engine) GetBackend() Backend

GetBackend is used to get the current Backend

func (*Engine) GetHandler

func (engine *Engine) GetHandler(p *module.Path) func(*Context)

GetHandler chooses which processor to use based on the requested path

func (*Engine) Interceptor

func (engine *Engine) Interceptor() gin.HandlerFunc

Interceptor intercepts all requests to process the GOPROXY part

func (*Engine) Run

func (engine *Engine) Run() error

Run is used to start the proxy

func (*Engine) SetBackend

func (engine *Engine) SetBackend(backend Backend)

SetBackend is used to switch backend used by proxy

type Fetcher

type Fetcher interface {
	List(*module.Module) (io.ReadCloser, error)
	Info(*module.Module) (io.ReadCloser, error)
	Latest(*module.Module) (io.ReadCloser, error)
	Mod(*module.Module) (io.ReadCloser, error)
	Zip(*module.Module) (io.ReadCloser, error)
}

Fetcher defined the interface of GORPOXY api

type StreamDestType

type StreamDestType uint8

StreamDestType defines the destination to process the request

const (
	StreamDestTypeUnknown StreamDestType = iota
	StreamDestTypeLocal
	StreamDestTypeUpstream
)

Define a set of common stream dest type

type StreamSplitter

type StreamSplitter interface {
	Split(c *Context) StreamDestType
}

StreamSplitter is used to separate requests, it determines whether a goproxy request should use upstream or local

type Worker

type Worker func(*module.Module) (io.ReadCloser, error)

Worker is an abstraction of a processing function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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