handlers

package
v0.0.0-...-47fbf8c Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateReplicas

func CalculateReplicas(status string, currentReplicas uint64, maxReplicas uint64, minReplicas uint64, scalingFactor uint64) uint64

CalculateReplicas decides what replica count to set depending on current/desired amount

func DecorateWithCORS

func DecorateWithCORS(upstream http.Handler, allowedHost string) http.Handler

DecorateWithCORS decorate a handler with CORS-injecting middleware

func HealthzHandler

func HealthzHandler(w http.ResponseWriter, r *http.Request)

HealthzHandler healthz hanlder for mertics server

func MakeAlertHandler

func MakeAlertHandler(service scaling.ServiceQuery, defaultNamespace string) http.HandlerFunc

MakeAlertHandler handles alerts from Prometheus Alertmanager

func MakeAsyncReport

func MakeAsyncReport(metrics metrics.MetricOptions) http.HandlerFunc

MakeAsyncReport makes a handler for asynchronous invocations to report back into.

func MakeCallIDMiddleware

func MakeCallIDMiddleware(next http.HandlerFunc) http.HandlerFunc

MakeCallIDMiddleware middleware tags a request with a uid

func MakeExternalAuthHandler

func MakeExternalAuthHandler(next http.HandlerFunc, upstreamTimeout time.Duration, upstreamURL string, passBody bool) http.HandlerFunc

MakeExternalAuthHandler make an authentication proxy handler

func MakeForwardingProxyHandler

func MakeForwardingProxyHandler(proxy *types.HTTPClientReverseProxy,
	notifiers []HTTPNotifier,
	baseURLResolver BaseURLResolver,
	urlPathTransformer URLPathTransformer,
	serviceAuthInjector AuthInjector) http.HandlerFunc

MakeForwardingProxyHandler create a handler which forwards HTTP requests

func MakeInfoHandler

func MakeInfoHandler(h http.Handler) http.HandlerFunc

MakeInfoHandler is responsible for display component version information

func MakeNotifierWrapper

func MakeNotifierWrapper(next http.HandlerFunc, notifiers []HTTPNotifier) http.HandlerFunc

MakeNotifierWrapper wraps a http.HandlerFunc in an interceptor to pass to HTTPNotifier

func MakeQueuedProxy

func MakeQueuedProxy(metrics metrics.MetricOptions, wildcard bool, canQueueRequests queue.CanQueueRequests, pathTransformer URLPathTransformer) http.HandlerFunc

MakeQueuedProxy accepts work onto a queue

func MakeScalingHandler

func MakeScalingHandler(next http.HandlerFunc, config scaling.ScalingConfig, defaultNamespace string) http.HandlerFunc

MakeScalingHandler creates handler which can scale a function from zero to N replica(s). After scaling the next http.HandlerFunc will be called. If the function is not ready after the configured amount of attempts / queries then next will not be invoked and a status will be returned to the client.

func NewLogHandlerFunc

func NewLogHandlerFunc(logProvider url.URL, timeout time.Duration) http.HandlerFunc

NewLogHandlerFunc creates and http HandlerFunc from the supplied log Requestor.

Types

type AuthInjector

type AuthInjector interface {
	Inject(r *http.Request)
}

type BaseURLResolver

type BaseURLResolver interface {
	Resolve(r *http.Request) string
}

BaseURLResolver URL resolver for upstream requests

type BasicAuthInjector

type BasicAuthInjector struct {
	Credentials *auth.BasicAuthCredentials
}

func (BasicAuthInjector) Inject

func (b BasicAuthInjector) Inject(r *http.Request)

type CORSHandler

type CORSHandler struct {
	Upstream    *http.Handler
	AllowedHost string
}

CORSHandler set custom CORS instructions for the store.

func (CORSHandler) ServeHTTP

func (c CORSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type FunctionAsHostBaseURLResolver

type FunctionAsHostBaseURLResolver struct {
	FunctionSuffix    string
	FunctionNamespace string
}

FunctionAsHostBaseURLResolver resolves URLs using a function from the URL as a host

func (FunctionAsHostBaseURLResolver) Resolve

Resolve the base URL for a request

type FunctionPrefixTrimmingURLPathTransformer

type FunctionPrefixTrimmingURLPathTransformer struct {
}

FunctionPrefixTrimmingURLPathTransformer removes the "/function/servicename/" prefix from the URL path.

func (FunctionPrefixTrimmingURLPathTransformer) Transform

Transform removes the "/function/servicename/" prefix from the URL path.

type HTTPNotifier

type HTTPNotifier interface {
	Notify(method string, URL string, originalURL string, statusCode int, duration time.Duration)
}

HTTPNotifier notify about HTTP request/response

type LoggingNotifier

type LoggingNotifier struct {
}

LoggingNotifier notifies a log about a request

func (LoggingNotifier) Notify

func (LoggingNotifier) Notify(method string, URL string, originalURL string, statusCode int, duration time.Duration)

Notify a log about a request

type PrometheusFunctionNotifier

type PrometheusFunctionNotifier struct {
	Metrics *metrics.MetricOptions
}

PrometheusFunctionNotifier records metrics to Prometheus

func (PrometheusFunctionNotifier) Notify

func (p PrometheusFunctionNotifier) Notify(method string, URL string, originalURL string, statusCode int, duration time.Duration)

Notify records metrics in Prometheus

type PrometheusServiceNotifier

type PrometheusServiceNotifier struct {
	ServiceMetrics *metrics.ServiceMetricOptions
}

PrometheusServiceNotifier notifier for core service endpoints

func (PrometheusServiceNotifier) Notify

func (psn PrometheusServiceNotifier) Notify(method string, URL string, originalURL string, statusCode int, duration time.Duration)

Notify about service metrics

type SingleHostBaseURLResolver

type SingleHostBaseURLResolver struct {
	BaseURL string
}

SingleHostBaseURLResolver resolves URLs against a single BaseURL

func (SingleHostBaseURLResolver) Resolve

Resolve the base URL for a request

type TransparentURLPathTransformer

type TransparentURLPathTransformer struct {
}

TransparentURLPathTransformer passes the requested URL path through untouched.

func (TransparentURLPathTransformer) Transform

Transform returns the URL path unchanged.

type URLPathTransformer

type URLPathTransformer interface {
	Transform(r *http.Request) string
}

URLPathTransformer Transform the incoming URL path for upstream requests

Jump to

Keyboard shortcuts

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