Documentation ¶
Index ¶
- Constants
- func AddRouterErrorHeader(rw http.ResponseWriter, val string)
- func CreateDomainAllowlist(allowlist []string) (map[string]struct{}, error)
- func EndpointIteratorForRequest(logger logger.Logger, request *http.Request, loadBalanceMethod string, ...) (route.EndpointIterator, error)
- func GetEndpoint(ctx context.Context) (*route.Endpoint, error)
- func GetStickySession(request *http.Request, stickySessionCookieNames config.StringSet, ...) (string, bool)
- func IsWebSocketUpgrade(request *http.Request) bool
- func LoggerWithTraceInfo(l logger.Logger, r *http.Request) logger.Logger
- func NewAccessLog(accessLogger accesslog.AccessLogger, extraHeadersToLog []string, ...) negroni.Handler
- func NewClientCert(skipSanitization func(req *http.Request) bool, ...) negroni.Handler
- func NewHTTPLatencyPrometheus(r Registry) negroni.Handler
- func NewHTTPRewriteHandler(cfg config.HTTPRewrite, headersToAlwaysRemove []string) negroni.Handler
- func NewHTTPStartStop(emitter dropsonde.EventEmitter, logger logger.Logger) negroni.Handler
- func NewHealthcheck(health *health.Health, logger logger.Logger) http.Handler
- func NewLookup(registry registry.Registry, rep metrics.ProxyReporter, logger logger.Logger, ...) negroni.Handler
- func NewPanicCheck(health *health.Health, logger logger.Logger) negroni.Handler
- func NewProtocolCheck(logger logger.Logger, errorWriter errorwriter.ErrorWriter, enableHTTP2 bool) negroni.Handler
- func NewProxyHealthcheck(userAgent string, health *health.Health) negroni.Handler
- func NewProxyWriter(logger logger.Logger) negroni.Handler
- func NewQueryParam(logger logger.Logger) negroni.Handler
- func NewReporter(reporter metrics.ProxyReporter, logger logger.Logger) negroni.Handler
- func NewRequestInfo() negroni.Handler
- func NewRouteService(config *routeservice.RouteServiceConfig, routeRegistry registry.Registry, ...) negroni.Handler
- func NewVcapRequestIdHeader(logger logger.Logger) negroni.Handler
- type HopByHop
- type InvalidInstanceHeaderError
- type MaxRequestSize
- type Registry
- type RequestInfo
- type RequestInfoHandler
- type RouteService
- func (r *RouteService) AllowRouteServiceHairpinningRequest(uri route.Uri) bool
- func (r *RouteService) ArrivedViaRouteService(req *http.Request, logger logger.Logger) (bool, error)
- func (r *RouteService) IsRouteServiceTraffic(req *http.Request) bool
- func (r *RouteService) MatchAllowlistHostname(host string) bool
- func (r *RouteService) ServeHTTP(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc)
- type TraceInfo
- type W3C
- func (m *W3C) HeadersToLog() []string
- func (m *W3C) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func (m *W3C) ServeNewTraceparent(rw http.ResponseWriter, r *http.Request, requestInfo *RequestInfo, ...)
- func (m *W3C) ServeUpdatedTraceparent(rw http.ResponseWriter, r *http.Request, requestInfo *RequestInfo, ...)
- type W3CTraceparent
- type W3CTracestate
- type W3CTracestateEntry
- type XForwardedProto
- type Zipkin
Constants ¶
const ( W3CTraceparentHeader = "traceparent" W3CTracestateHeader = "tracestate" W3CVendorID = "gorouter" )
const ( W3CTraceparentVersion = uint8(0) W3CTraceparentSampled = uint8(1) W3CTraceparentNotSampled = uint8(0) )
const CfAppInstance = "X-CF-APP-INSTANCE"
const ONE_MB = 1024 * 1024 // bytes * kb
const RequestInfoCtxKey key = "RequestInfo"
const (
VcapCookieId = "__VCAP_ID__"
)
const (
VcapRequestIdHeader = "X-Vcap-Request-Id"
)
Variables ¶
This section is empty.
Functions ¶
func AddRouterErrorHeader ¶
func AddRouterErrorHeader(rw http.ResponseWriter, val string)
func CreateDomainAllowlist ¶
CreateDomainAllowlist collects the static parts of wildcard allowlist expressions and wildcards stripped of their first segment.
Each entry is checked to follow DNS wildcard notation, e.g. *.domain-123.com, subdomain.example.com
but not subdomain.*.example.com, *.*.example.com or invalid DNS names, e.g. ?!.example.com
This function is exported so it can be tested as part of the route service test
func GetStickySession ¶
func IsWebSocketUpgrade ¶
func NewAccessLog ¶
func NewAccessLog( accessLogger accesslog.AccessLogger, extraHeadersToLog []string, logAttemptsDetails bool, logger logger.Logger, ) negroni.Handler
NewAccessLog creates a new handler that handles logging requests to the access log
func NewClientCert ¶
func NewHTTPLatencyPrometheus ¶
func NewHTTPLatencyPrometheus(r Registry) negroni.Handler
NewHTTPLatencyPrometheus creates a new handler that handles prometheus metrics for latency
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 frontend HTTP StartStop events
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 ¶
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, enableHTTP2 bool) negroni.Handler
NewProtocolCheck creates a handler responsible for checking the protocol of the request
func NewProxyHealthcheck ¶
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 ¶
NewProxyWriter creates a handler responsible for setting a proxy responseWriter on the request and response
func NewQueryParam ¶
NewQueryParam creates a new handler that emits warnings if requests came in with semicolons un-escaped
func NewReporter ¶
func NewReporter(reporter metrics.ProxyReporter, logger logger.Logger) negroni.Handler
NewReporter creates a new handler that handles reporting backend responses to metrics and missing Content-Length header
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 ¶
Types ¶
type HopByHop ¶
type HopByHop struct {
// contains filtered or unexported fields
}
func NewHopByHop ¶
NewHopByHop creates a new handler that sanitizes hop-by-hop headers based on the HopByHopHeadersToFilter config
func (*HopByHop) SanitizeRequestConnection ¶
func (*HopByHop) ServeHTTP ¶
func (h *HopByHop) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type InvalidInstanceHeaderError ¶
type InvalidInstanceHeaderError struct {
// contains filtered or unexported fields
}
func (InvalidInstanceHeaderError) Error ¶
func (err InvalidInstanceHeaderError) Error() string
type MaxRequestSize ¶
type MaxRequestSize struct { MaxSize int // contains filtered or unexported fields }
func NewMaxRequestSize ¶
func NewMaxRequestSize(cfg *config.Config, logger logger.Logger) *MaxRequestSize
NewAccessLog creates a new handler that handles logging requests to the access log
func (*MaxRequestSize) ServeHTTP ¶
func (m *MaxRequestSize) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type RequestInfo ¶
type RequestInfo struct { // ReceivedAt records the time at which this request was received by // gorouter as recorded in the RequestInfo middleware. ReceivedAt time.Time // AppRequestStartedAt records the time at which gorouter starts sending // the request to the backend. AppRequestStartedAt time.Time // LastFailedAttemptFinishedAt is the end of the last failed request, // if any. If there was at least one failed attempt this will be set, if // there was no successful attempt the RequestFailed flag will be set. LastFailedAttemptFinishedAt time.Time // These times document at which timestamps the individual phases of the // request started / finished if there was a successful attempt. DnsStartedAt time.Time DnsFinishedAt time.Time DialStartedAt time.Time DialFinishedAt time.Time TlsHandshakeStartedAt time.Time TlsHandshakeFinishedAt time.Time // AppRequestFinishedAt records the time at which either a response was // received or the last performed attempt failed and no further attempts // could be made. AppRequestFinishedAt time.Time // FinishedAt is recorded once the access log middleware is executed after // performing the request, in contrast to the ReceivedAt value which is // recorded before the access log, but we need the value to be able to // produce the log. FinishedAt time.Time RoutePool *route.EndpointPool RouteEndpoint *route.Endpoint ProxyResponseWriter utils.ProxyResponseWriter RouteServiceURL *url.URL ShouldRouteToInternalRouteService bool FailedAttempts int // RoundTripSuccessful will be set once a request has successfully reached a backend instance. RoundTripSuccessful bool TraceInfo TraceInfo BackendReqHeaders http.Header }
RequestInfo stores all metadata about the request and is used to pass information between handlers. The timing information is ordered by time of occurrence.
func ContextRequestInfo ¶
func ContextRequestInfo(req *http.Request) (*RequestInfo, error)
ContextRequestInfo gets the RequestInfo from the request Context
func (*RequestInfo) ProvideTraceInfo ¶
func (r *RequestInfo) ProvideTraceInfo() (TraceInfo, error)
func (*RequestInfo) SetTraceInfo ¶
func (r *RequestInfo) SetTraceInfo(traceID, spanID string) error
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) AllowRouteServiceHairpinningRequest ¶
func (r *RouteService) AllowRouteServiceHairpinningRequest(uri route.Uri) bool
AllowRouteServiceHairpinningRequest decides whether a route service request can be resolved internally via the route registry or should be handled as external request. If the provided route is not known to this gorouter's route registry, the request will always be external. If the route is known, the hairpinning allowlist is consulted (if defined).
Only routes with host names that match an entry on the allowlist are resolved internally. Should the allowlist be empty, it is considered disabled and will allow internal resolution of any request that can be resolved via the gorouter's route registry.
returns true to use internal resolution via this gorouter, false for external resolution via route service URL call.
func (*RouteService) ArrivedViaRouteService ¶
func (*RouteService) IsRouteServiceTraffic ¶
func (r *RouteService) IsRouteServiceTraffic(req *http.Request) bool
func (*RouteService) MatchAllowlistHostname ¶
func (r *RouteService) MatchAllowlistHostname(host string) bool
MatchAllowlistHostname checks, if the provided host name matches an entry as is, or matches a wildcard when stripping the first segment.
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 (*W3C) HeadersToLog ¶
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, requestInfo *RequestInfo, logger logger.Logger)
func (*W3C) ServeUpdatedTraceparent ¶
func (m *W3C) ServeUpdatedTraceparent( rw http.ResponseWriter, r *http.Request, requestInfo *RequestInfo, prevTraceparent W3CTraceparent, logger logger.Logger, )
type W3CTraceparent ¶
W3CTraceparent is a struct which represents the traceparent header See https://www.w3.org/TR/trace-context/
func NewW3CTraceparent ¶
func NewW3CTraceparent(requestInfo *RequestInfo) (W3CTraceparent, error)
NewW3CTraceparent returns W3C traceparent header value according to https://www.w3.org/TR/trace-context/#version-format It uses trace ID and span ID provided in the request context Or generates new IDs
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 ¶
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 }
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 (*Zipkin) HeadersToLog ¶
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)
Source Files ¶
- access_log.go
- clientcert.go
- healthcheck.go
- helpers.go
- hop_by_hop.go
- http_rewrite.go
- httplatencyprometheus.go
- httpstartstop.go
- lookup.go
- max_request_size.go
- paniccheck.go
- protocolcheck.go
- proxy_healthcheck.go
- proxywriter.go
- query_param.go
- reporter.go
- request_id.go
- requestinfo.go
- routeservice.go
- w3c.go
- w3c_traceparent.go
- w3c_tracestate.go
- x_forwarded_proto.go
- zipkin.go