middleware

package
v0.0.0-...-eac6ddc Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTokenFromCtx

func GetTokenFromCtx(ctx context.Context) (string, error)

GetTokenFromCtx extracts the token from the context

func InjectContextWithMockToken

func InjectContextWithMockToken(ctx context.Context, token string, serviceName string) context.Context

InjectContextWithMockToken injects a token into the context. Useful for testing

func IsAuthenticated

func IsAuthenticated(ctx context.Context) bool

IsAuthenticated returns wether or not the user is authenticated. REQUIRES Middleware to have run.

func RandomErrorMiddleware

func RandomErrorMiddleware(next http.Handler) http.Handler

func RequestTime

func RequestTime(next http.Handler) http.Handler

func VersionMiddleware

func VersionMiddleware(next http.Handler) http.Handler

Types

type AuthnMW

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

func NewAuthnMiddleware

func NewAuthnMiddleware(c *core_auth_sdk.Client, log *zap.Logger, serviceName string) *AuthnMW

NewAuthnMiddleware returns a new instance of the authentication middleware

func (*AuthnMW) AuthenticationMiddleware

func (mw *AuthnMW) AuthenticationMiddleware(next http.HandlerFunc) http.HandlerFunc

AuthenticationMiddleware wraps the authentication middleware around an http call

type CorsMw

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

func NewCorsMiddleware

func NewCorsMiddleware(origins []string) *CorsMw

NewCorsMiddleware returns a new instance of the cors middleware

func (*CorsMw) CorsMiddleware

func (c *CorsMw) CorsMiddleware(next http.Handler) http.Handler

CorsMiddleware runs the Cors middleware

type LoggingMiddleware

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

func NewLoggingMiddleware

func NewLoggingMiddleware(logger *zap.Logger) *LoggingMiddleware

func (*LoggingMiddleware) Handler

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

type PrometheusMiddleware

type PrometheusMiddleware struct {
	Histogram *prometheus.HistogramVec
	Counter   *prometheus.CounterVec
}

func NewPrometheusMiddleware

func NewPrometheusMiddleware() *PrometheusMiddleware

func (*PrometheusMiddleware) Handler

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

Metrics godoc @Summary Prometheus metrics @Description returns HTTP requests duration and Go runtime metrics @Tags Kubernetes @Produce plain @Router /metrics [get] @Success 200 {string} string "OK"

type RandomDelayMiddleware

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

func NewRandomDelayMiddleware

func NewRandomDelayMiddleware(minDelay, maxDelay int, delayUnit string) *RandomDelayMiddleware

func (*RandomDelayMiddleware) Handler

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

Jump to

Keyboard shortcuts

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