middleware

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIKeyAuthMiddleware added in v1.1.1

func APIKeyAuthMiddleware(validator func(apiKey string) bool, apiKeys ...string) func(handler http.Handler) http.Handler

func BasicAuthMiddleware added in v1.1.1

func BasicAuthMiddleware(basicAuthProvider BasicAuthProvider) func(handler http.Handler) http.Handler

func CORS

func CORS() func(inner http.Handler) http.Handler

func Logging

func Logging(logger logger) func(inner http.Handler) http.Handler

Logging is a middleware which logs response status and time in microseconds along with other data.

func Metrics added in v0.3.0

func Metrics(metrics metrics) func(inner http.Handler) http.Handler

func OAuth added in v1.1.1

func OAuth(key PublicKeyProvider) func(inner http.Handler) http.Handler

func Tracer

func Tracer(inner http.Handler) http.Handler

Types

type BasicAuthProvider added in v1.1.1

type BasicAuthProvider struct {
	Users        map[string]string
	ValidateFunc func(username, password string) bool
}

type JSONWebKey added in v1.1.1

type JSONWebKey struct {
	ID   string `json:"kid"`
	Type string `json:"kty"`

	Modulus         string `json:"n"`
	PublicExponent  string `json:"e"`
	PrivateExponent string `json:"d"`
}

type JWKNotFound added in v1.1.1

type JWKNotFound struct {
}

func (JWKNotFound) Error added in v1.1.1

func (i JWKNotFound) Error() string

type JWKS added in v1.1.1

type JWKS struct {
	Keys []JSONWebKey `json:"keys"`
}

JWKS represents a JSON Web Key Set.

type JWKSProvider added in v1.1.1

type JWKSProvider interface {
	GetWithHeaders(ctx context.Context, path string, queryParams map[string]interface{},
		headers map[string]string) (*http.Response, error)
}

type JWTClaim added in v1.1.1

type JWTClaim string

type OauthConfigs added in v1.1.1

type OauthConfigs struct {
	Provider        JWKSProvider
	RefreshInterval time.Duration
}

type PublicKeyProvider added in v1.1.1

type PublicKeyProvider interface {
	Get(kid string) *rsa.PublicKey
}

func NewOAuth added in v1.1.1

func NewOAuth(config OauthConfigs) PublicKeyProvider

type PublicKeys added in v1.1.1

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

func (*PublicKeys) Get added in v1.1.1

func (p *PublicKeys) Get(kid string) *rsa.PublicKey

type RequestLog

type RequestLog struct {
	TraceID      string `json:"trace_id,omitempty"`
	SpanID       string `json:"span_id,omitempty"`
	StartTime    string `json:"start_time,omitempty"`
	ResponseTime int64  `json:"response_time,omitempty"`
	Method       string `json:"method,omitempty"`
	UserAgent    string `json:"user_agent,omitempty"`
	IP           string `json:"ip,omitempty"`
	URI          string `json:"uri,omitempty"`
	Response     int    `json:"response,omitempty"`
}

type StatusResponseWriter

type StatusResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

StatusResponseWriter Defines own Response Writer to be used for logging of status - as http.ResponseWriter does not let us read status.

func (*StatusResponseWriter) WriteHeader

func (w *StatusResponseWriter) WriteHeader(status int)

Jump to

Keyboard shortcuts

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