httptee

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneURL

func CloneURL(u *url.URL) *url.URL

CloneURL clones a URL.

func DuplicateRequest

func DuplicateRequest(request *http.Request) *http.Request

DuplicateRequest duplicate http req

func InsertForwardedHeaders

func InsertForwardedHeaders(request *http.Request)

InsertForwardedHeaders insert header X-Forwarded-For and Forwarded headers.

func MakeTransport

func MakeTransport(t time.Duration, closeConnections bool) *http.Transport

MakeTransport makes a new http.Transport.

func SetRequestTarget

func SetRequestTarget(request *http.Request, b Backend)

SetRequestTarget sets the req URL. this turns a inbound req (a req without URL) into an outbound req.

Types

type AlternativeReq

type AlternativeReq struct {
	Handler *Handler
	// contains filtered or unexported fields
}

AlternativeReq represents the alternative request.

func (AlternativeReq) Run

func (r AlternativeReq) Run() error

Run Do do the request.

type Backend

type Backend struct {
	Host string
	Addr *url.URL
}

Backend represents the backend server.

func (*Backend) ParseAddress

func (b *Backend) ParseAddress(addr string) (err error)

ParseAddress parses an address to https, host(ip:port)

type Handler

type Handler struct {
	Alternatives []Backend
	// contains filtered or unexported fields
}

Handler contains the address of the main PrimaryTarget and the one for the Host target

func CreateHandler

func CreateHandler(addrs string) (*Handler, error)

func (*Handler) Tee

func (h *Handler) Tee(req *http.Request)

Tee duplicates the incoming req (req) and does the req to the

type Pool

type Pool interface {
	Run(ctx context.Context, job Runnable) error
}

Pool means the pool that can be run by pooling workers.

func NewWorkerPool

func NewWorkerPool(maxWorkers int) Pool

NewWorkerPool creates a limited pool of permissions in order to limit the number of concurrent jobs.

type Runnable

type Runnable interface {
	Run() error
}

Runnable means anythings that can be run.

type WorkerPool

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

WorkerPool carries a pool to deliver job.

func (WorkerPool) Run

func (p WorkerPool) Run(ctx context.Context, job Runnable) error

Run runs the job by the worker.

Jump to

Keyboard shortcuts

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