middleware

package
v0.0.0-...-3c4ad8c Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessTokenFrom

func AccessTokenFrom(ctx context.Context) (string, bool)

func CorrelationIDHandler

func CorrelationIDHandler(next http.Handler) http.Handler

func Cors

func Cors(cfg *config.Config, methods []string) func(http.Handler) http.Handler

func IngressFrom

func IngressFrom(ctx context.Context) (ingress.Ingress, bool)

func LogEntryFrom

func LogEntryFrom(r *http.Request) *log.Entry

func PathFrom

func PathFrom(ctx context.Context) (string, bool)

func RequestWithIngress

func RequestWithIngress(r *http.Request, ing ingress.Ingress) *http.Request

func RequestWithPath

func RequestWithPath(r *http.Request, path string) *http.Request

func WithAccessToken

func WithAccessToken(ctx context.Context, accessToken string) context.Context

func WithIngress

func WithIngress(ctx context.Context, ingress ingress.Ingress) context.Context

func WithPath

func WithPath(ctx context.Context, path string) context.Context

Types

type IngressMiddleware

type IngressMiddleware struct {
	IngressSource
}

func Ingress

func Ingress(source IngressSource) IngressMiddleware

func (*IngressMiddleware) Handler

func (i *IngressMiddleware) Handler(next http.Handler) http.Handler

type IngressSource

type IngressSource interface {
	GetIngresses() *ingress.Ingresses
}

type LogEntryMiddleware

type LogEntryMiddleware struct{}

func LogEntry

func LogEntry(provider string) LogEntryMiddleware

LogEntry is copied verbatim from httplog package to replace with our own requestLogger implementation.

func (*LogEntryMiddleware) Handler

func (l *LogEntryMiddleware) Handler(next http.Handler) http.Handler

type PrometheusMiddleware

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

PrometheusMiddleware is a handler that exposes prometheus metrics for the number of requests, the latency and the response size, partitioned by status code, method and HTTP path.

func Prometheus

func Prometheus(provider string, buckets ...float64) *PrometheusMiddleware

Prometheus returns a new PrometheusMiddleware handler.

func (*PrometheusMiddleware) Handler

func (m *PrometheusMiddleware) Handler(next http.Handler) http.Handler

func (*PrometheusMiddleware) Initialize

func (m *PrometheusMiddleware) Initialize(path, method string, code int)

Jump to

Keyboard shortcuts

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