middleware

package
v7.0.0-...-1c7ecba Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMetricsHandler = NewMetricsHandlerWithDefaultRegistry()

DefaultMetricsHandler is the default http.Handler for serving metrics from the default prometheus.Registry

Functions

func NewBasicAuthSessionLoader

func NewBasicAuthSessionLoader(validator basic.Validator, sessionGroups []string, preferEmail bool) alice.Constructor

func NewHealthCheck

func NewHealthCheck(paths, userAgents []string) alice.Constructor

func NewJwtSessionLoader

func NewJwtSessionLoader(sessionLoaders []middlewareapi.TokenToSessionFunc) alice.Constructor

func NewMetricsHandler

func NewMetricsHandler(registerer prometheus.Registerer, gatherer prometheus.Gatherer) http.Handler

NewMetricsHandler creates a new http.Handler for serving metrics from the provided prometheus.Registerer and prometheus.Gatherer

func NewMetricsHandlerWithDefaultRegistry

func NewMetricsHandlerWithDefaultRegistry() http.Handler

NewMetricsHandlerWithDefaultRegistry creates a new http.Handler for serving metrics from the default prometheus.Registry.

func NewReadynessCheck

func NewReadynessCheck(path string, verifiable Verifiable) alice.Constructor

NewReadynessCheck returns a middleware that performs deep health checks (verifies the connection to any underlying store) on a specific `path`

func NewRedirectToHTTPS

func NewRedirectToHTTPS(httpsPort string) alice.Constructor

NewRedirectToHTTPS creates a new redirectToHTTPS middleware that will redirect HTTP requests to HTTPS

func NewRequestHeaderInjector

func NewRequestHeaderInjector(headers []options.Header) (alice.Constructor, error)

func NewRequestLogger

func NewRequestLogger() alice.Constructor

NewRequestLogger returns middleware which logs requests It uses a custom ResponseWriter to track status code & response size details

func NewRequestMetrics

func NewRequestMetrics(registerer prometheus.Registerer) alice.Constructor

NewRequestMetrics returns a middleware that will record metrics for HTTP requests to the provided prometheus.Registerer

func NewRequestMetricsWithDefaultRegistry

func NewRequestMetricsWithDefaultRegistry() alice.Constructor

NewRequestMetricsWithDefaultRegistry returns a middleware that will record metrics for HTTP requests to the default prometheus.Registry

func NewResponseHeaderInjector

func NewResponseHeaderInjector(headers []options.Header) (alice.Constructor, error)

func NewScope

func NewScope(reverseProxy bool, idHeader string) alice.Constructor

func NewStoredSessionLoader

func NewStoredSessionLoader(opts *StoredSessionLoaderOptions) alice.Constructor

NewStoredSessionLoader creates a new storedSessionLoader which loads sessions from the session store. If no session is found, the request will be passed to the nex handler. If a session was loader by a previous handler, it will not be replaced.

Types

type StoredSessionLoaderOptions

type StoredSessionLoaderOptions struct {
	// Session storage backend
	SessionStore sessionsapi.SessionStore

	// How often should sessions be refreshed
	RefreshPeriod time.Duration

	// Provider based session refreshing
	RefreshSession func(context.Context, *sessionsapi.SessionState) (bool, error)

	// Provider based session validation.
	// If the sesssion is older than `RefreshPeriod` but the provider doesn't
	// refresh it, we must re-validate using this validation.
	ValidateSession func(context.Context, *sessionsapi.SessionState) bool
}

StoredSessionLoaderOptions contains all of the requirements to construct a stored session loader. All options must be provided.

type Verifiable

type Verifiable interface {
	VerifyConnection(context.Context) error
}

Verifiable an interface for an object that has a connection to external data source and exports a function to validate that connection

Jump to

Keyboard shortcuts

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