handlers

package
v0.0.0-...-68fb24b Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 1 more Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	W3CTraceparentHeader = "traceparent"
	W3CTracestateHeader  = "tracestate"

	W3CVendorID = "gorouter"
)
View Source
const (
	W3CTraceparentVersion    = uint8(0)
	W3CTraceparentSampled    = uint8(1)
	W3CTraceparentNotSampled = uint8(0)
)
View Source
const (
	B3Header             = "b3"
	B3TraceIdHeader      = "X-B3-TraceId"
	B3SpanIdHeader       = "X-B3-SpanId"
	B3ParentSpanIdHeader = "X-B3-ParentSpanId"
	B3SampledHeader      = "X-B3-Sampled"
	B3FlagsHeader        = "X-B3-Flags"
)
View Source
const CfAppInstance = "X-CF-APP-INSTANCE"
View Source
const (
	VcapRequestIdHeader = "X-Vcap-Request-Id"
)

Variables

This section is empty.

Functions

func AddRouterErrorHeader

func AddRouterErrorHeader(rw http.ResponseWriter, val string)

func BuildB3SingleHeader

func BuildB3SingleHeader(traceID, spanID, sampling, flags, parentSpanID string) string

BuildB3SingleHeader assembles the B3 single header based on existing trace values

func GetEndpoint

func GetEndpoint(ctx context.Context) (*route.Endpoint, error)

func IsWebSocketUpgrade

func IsWebSocketUpgrade(request *http.Request) bool

func NewAccessLog

func NewAccessLog(
	accessLogger accesslog.AccessLogger,
	extraHeadersToLog []string,
	logger logger.Logger,
) negroni.Handler

NewAccessLog creates a new handler that handles logging requests to the access log

func NewClientCert

func NewClientCert(
	skipSanitization func(req *http.Request) bool,
	forceDeleteHeader func(req *http.Request) (bool, error),
	forwardingMode string,
	logger logger.Logger,
	ew errorwriter.ErrorWriter,
) negroni.Handler

func NewHTTPRewriteHandler

func NewHTTPRewriteHandler(cfg config.HTTPRewrite, headersToAlwaysRemove []string) negroni.Handler

func NewHTTPStartStop

func NewHTTPStartStop(emitter dropsonde.EventEmitter, logger logger.Logger) negroni.Handler

NewHTTPStartStop creates a new handler that handles emitting frontent HTTP StartStop events

func NewHealthcheck

func NewHealthcheck(health *health.Health, logger logger.Logger) http.Handler

func NewLookup

func NewLookup(
	registry registry.Registry,
	rep metrics.ProxyReporter,
	logger logger.Logger,
	ew errorwriter.ErrorWriter,
	emptyPoolResponseCode503 bool,
) negroni.Handler

NewLookup creates a handler responsible for looking up a route.

func NewPanicCheck

func NewPanicCheck(health *health.Health, logger logger.Logger) negroni.Handler

NewPanicCheck creates a handler responsible for checking for panics and setting the Healthcheck to fail.

func NewProtocolCheck

func NewProtocolCheck(logger logger.Logger, errorWriter errorwriter.ErrorWriter) negroni.Handler

NewProtocolCheck creates a handler responsible for checking the protocol of the request

func NewProxyHealthcheck

func NewProxyHealthcheck(userAgent string, health *health.Health, logger logger.Logger) negroni.Handler

NewHealthcheck creates a handler that responds to healthcheck requests. If userAgent is set to a non-empty string, it will use that user agent to differentiate between healthcheck requests and non-healthcheck requests. Otherwise, it will treat all requests as healthcheck requests.

func NewProxyWriter

func NewProxyWriter(logger logger.Logger) negroni.Handler

NewProxyWriter creates a handler responsible for setting a proxy responseWriter on the request and response

func NewReporter

func NewReporter(reporter metrics.ProxyReporter, logger logger.Logger) negroni.Handler

NewReporter creates a new handler that handles reporting backend responses to metrics

func NewRequestInfo

func NewRequestInfo() negroni.Handler

NewRequestInfo creates a RequestInfoHandler

func NewRouteService

func NewRouteService(
	config *routeservice.RouteServiceConfig,
	routeRegistry registry.Registry,
	logger logger.Logger,
	errorWriter errorwriter.ErrorWriter,
) negroni.Handler

NewRouteService creates a handler responsible for handling route services

func NewVcapRequestIdHeader

func NewVcapRequestIdHeader(logger logger.Logger) negroni.Handler

Types

type InvalidInstanceHeaderError

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

func (InvalidInstanceHeaderError) Error

func (err InvalidInstanceHeaderError) Error() string

type RequestInfo

type RequestInfo struct {
	StartedAt, StoppedAt                      time.Time
	AppRequestStartedAt, AppRequestFinishedAt time.Time
	RoutePool                                 *route.EndpointPool
	RouteEndpoint                             *route.Endpoint
	ProxyResponseWriter                       utils.ProxyResponseWriter
	RouteServiceURL                           *url.URL
	ShouldRouteToInternalRouteService         bool

	BackendReqHeaders http.Header
}

RequestInfo stores all metadata about the request and is used to pass informaton between handlers

func ContextRequestInfo

func ContextRequestInfo(req *http.Request) (*RequestInfo, error)

ContextRequestInfo gets the RequestInfo from the request Context

type RequestInfoHandler

type RequestInfoHandler struct{}

RequestInfoHandler adds a RequestInfo to the context of all requests that go through this handler

func (*RequestInfoHandler) ServeHTTP

func (r *RequestInfoHandler) ServeHTTP(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)

type RouteService

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

func (*RouteService) ArrivedViaRouteService

func (r *RouteService) ArrivedViaRouteService(req *http.Request) (bool, error)

func (*RouteService) IsRouteServiceTraffic

func (r *RouteService) IsRouteServiceTraffic(req *http.Request) bool

func (*RouteService) ServeHTTP

func (r *RouteService) ServeHTTP(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc)

type W3C

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

W3C is a handler that sets W3C headers on requests

func NewW3C

func NewW3C(enabled bool, tenantID string, logger logger.Logger) *W3C

NewW3C creates a new handler that sets W3C headers on requests

func (*W3C) HeadersToLog

func (m *W3C) HeadersToLog() []string

HeadersToLog specifies the headers which should be logged if W3C headers are enabled

func (*W3C) ServeHTTP

func (m *W3C) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func (*W3C) ServeNewTraceparent

func (m *W3C) ServeNewTraceparent(rw http.ResponseWriter, r *http.Request)

func (*W3C) ServeUpdatedTraceparent

func (m *W3C) ServeUpdatedTraceparent(
	rw http.ResponseWriter,
	r *http.Request,
	prevTraceparent W3CTraceparent,
)

type W3CTraceparent

type W3CTraceparent struct {
	Version  uint8
	TraceID  []byte
	ParentID []byte
	Flags    uint8
}

W3CTraceparent is a struct which represents the traceparent header See https://www.w3.org/TR/trace-context/

func NewW3CTraceparent

func NewW3CTraceparent() (W3CTraceparent, error)

NewW3CTraceparent generates a W3C traceparent header value according to https://www.w3.org/TR/trace-context/#version-format

func ParseW3CTraceparent

func ParseW3CTraceparent(header string) *W3CTraceparent

ParseW3CTraceparent parses a W3C traceparent header value according to https://www.w3.org/TR/trace-context/#version-format If it cannot parse the input header string it returns nil

func (W3CTraceparent) Next

func (h W3CTraceparent) Next() (W3CTraceparent, error)

Next generates a new Traceparent

func (W3CTraceparent) String

func (h W3CTraceparent) String() string

String generates the W3C traceparent header value according to https://www.w3.org/TR/trace-context/#version-format

type W3CTracestate

type W3CTracestate []W3CTracestateEntry

W3CTracestate is an alias for a slice W3CTracestateEntry; has helper funcs

func NewW3CTracestate

func NewW3CTracestate(tenantID string, parentID []byte) W3CTracestate

NewW3CTracestate generates a new set of W3C tracestate pairs according to https://www.w3.org/TR/trace-context/#version-format Initially it is populated with the current tracestate determined by arguments tenantID and parentID

func ParseW3CTracestate

func ParseW3CTracestate(header string) W3CTracestate

func (W3CTracestate) Next

func (s W3CTracestate) Next(tenantID string, parentID []byte) W3CTracestate

func (W3CTracestate) String

func (s W3CTracestate) String() string

type W3CTracestateEntry

type W3CTracestateEntry struct {
	Key string
	Val string
}

W3CTracestateEntry represents a Tracestate entry: a key value pair

func NextW3CTracestate

func NextW3CTracestate(tenantID string, parentID []byte) W3CTracestateEntry

func (W3CTracestateEntry) String

func (s W3CTracestateEntry) String() string

type XForwardedProto

type XForwardedProto struct {
	SkipSanitization         func(req *http.Request) bool
	ForceForwardedProtoHttps bool
	SanitizeForwardedProto   bool
	Logger                   logger.Logger
}

func (*XForwardedProto) ServeHTTP

func (h *XForwardedProto) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Zipkin

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

Zipkin is a handler that sets Zipkin headers on requests

func NewZipkin

func NewZipkin(enabled bool, logger logger.Logger) *Zipkin

NewZipkin creates a new handler that sets Zipkin headers on requests

func (*Zipkin) HeadersToLog

func (z *Zipkin) HeadersToLog() []string

HeadersToLog specifies the headers which should be logged if Zipkin headers are enabled

func (*Zipkin) ServeHTTP

func (z *Zipkin) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Jump to

Keyboard shortcuts

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