Documentation ¶
Index ¶
- func GetTokenFromCtx(ctx context.Context) (string, error)
- func InjectContextWithMockToken(ctx context.Context, token string, serviceName string) context.Context
- func IsAuthenticated(ctx context.Context) bool
- type AuthnMW
- type CorsMw
- type LoggingMiddleware
- type PrometheusMiddleware
- type RandomDelayMiddleware
- type RandomErrMw
- type VersionrMw
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTokenFromCtx ¶
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 ¶
IsAuthenticated returns wether or not the user is authenticated. REQUIRES Middleware to have run.
Types ¶
type AuthnMW ¶
type AuthnMW struct {
// contains filtered or unexported fields
}
func NewAuthnMw ¶
func NewAuthnMw(c *core_auth_sdk.Client, log core_logging.ILog, serviceName string) *AuthnMW
NewAuthnMw returns a new instance of the authentication middleware
type CorsMw ¶
type CorsMw struct {
// contains filtered or unexported fields
}
type LoggingMiddleware ¶
type LoggingMiddleware struct { }
func NewLoggingMiddleware ¶
func NewLoggingMiddleware() *LoggingMiddleware
NewLoggingMiddleware returns a new instance of the logging middleware
func (*LoggingMiddleware) LoggingMiddleware ¶
func (m *LoggingMiddleware) LoggingMiddleware(next http.Handler) http.Handler
LoggingMiddleware runs the logging middleware
type PrometheusMiddleware ¶
type PrometheusMiddleware struct { Histogram *core_metrics.HistogramVec Counter *core_metrics.CounterVec }
func NewPrometheusMiddleware ¶
func NewPrometheusMiddleware(h *core_metrics.HistogramVec, c *core_metrics.CounterVec) *PrometheusMiddleware
NewPrometheusMiddleware returns an instance of the middleware object
func (*PrometheusMiddleware) MetricsMiddleware ¶
func (p *PrometheusMiddleware) MetricsMiddleware(next http.Handler) http.Handler
MetricsMiddleware returns HTTP requests duration and Go runtime metrics
type RandomDelayMiddleware ¶
type RandomDelayMiddleware struct {
// contains filtered or unexported fields
}
func NewRandomDelayMiddleware ¶
func NewRandomDelayMiddleware(minDelay, maxDelay int, delayUnit string) *RandomDelayMiddleware
NewRandomDelayMiddleware returns an instance of the random delay middleware
func (*RandomDelayMiddleware) DelayMiddleware ¶
func (m *RandomDelayMiddleware) DelayMiddleware(next http.Handler) http.Handler
DelayMiddleware runs the random delay middleware
type RandomErrMw ¶
type RandomErrMw struct{}
func NewRandomErrMw ¶
func NewRandomErrMw() *RandomErrMw
NewRandomErrMw returns a new instance of the random errors middleware
func (*RandomErrMw) RandomErrorMiddleware ¶
func (mw *RandomErrMw) RandomErrorMiddleware(next http.Handler) http.Handler
RandomErrorMiddleware runs the random error middleware
type VersionrMw ¶
type VersionrMw struct {
// contains filtered or unexported fields
}
func NewVersionMw ¶
func NewVersionMw(version string) *VersionrMw
NewVersionMw returns a new instance of the version errors middleware
func (*VersionrMw) VersionMiddleware ¶
func (mw *VersionrMw) VersionMiddleware(next http.Handler) http.Handler
VersionMiddleware runs the version middleware