httpstrangler

package module
v0.0.0-...-29230d5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 12 Imported by: 0

README

http-strangler

HTTP handler implementation of the Strangler Fig pattern.

TODO

  • Pass through response recorder
  • Tests and documentation
  • Request body buffering for proxy manager?

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(manager ProxyManager, defaultHandler, alternativeHandler http.Handler, options ...Option) http.Handler

func NewHandlerFromURLs

func NewHandlerFromURLs(manager ProxyManager, defaultURL, alternativeURL *url.URL, options ...Option) http.Handler

Types

type CMPDiffer

type CMPDiffer struct{}

func (CMPDiffer) Diff

func (C CMPDiffer) Diff(defaultResp, alternativeResp *Response) string

type DiffReporter

type DiffReporter interface {
	ReportMatch(req *http.Request)
	ReportDiff(req *http.Request, diff string)
	ReportError(req *http.Request, err error)
}

type Differ

type Differ interface {
	Diff(defaultResp, alternativeResp *Response) string
}

type Option

type Option func(*diffingOrchestrator)

func WithAlternativeContext

func WithAlternativeContext(ctxConstructor func(sourceCtx context.Context) context.Context) Option

func WithAlternativeTimeout

func WithAlternativeTimeout(timeout time.Duration) Option

func WithDiffReporter

func WithDiffReporter(reporter DiffReporter) Option

func WithDiffer

func WithDiffer(differ Differ) Option

type PrintDiffReporter

type PrintDiffReporter struct{}

func (PrintDiffReporter) ReportDiff

func (p PrintDiffReporter) ReportDiff(req *http.Request, diff string)

func (PrintDiffReporter) ReportError

func (p PrintDiffReporter) ReportError(req *http.Request, err error)

func (PrintDiffReporter) ReportMatch

func (p PrintDiffReporter) ReportMatch(req *http.Request)

type ProxyManager

type ProxyManager interface {
	GetProxyMode(r *http.Request) ProxyMode
}

type ProxyMode

type ProxyMode int
const (
	ProxyModeUseDefault ProxyMode = iota
	ProxyModeUseAlternative
	ProxyModeUseDefaultAndDiff
)

type Response

type Response struct {
	Headers    http.Header
	StatusCode int
	Body       any
}

Jump to

Keyboard shortcuts

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