Documentation
¶
Index ¶
- Constants
- Variables
- func BasicAuth(username string, passwordHash []byte, opts ...BasicAuthOption) keelhttp.Middleware
- func BasicAuthWithOptions(username string, passwordHash []byte, opts BasicAuthOptions) keelhttp.Middleware
- func CORS(opts ...CORSOption) keelhttp.Middleware
- func CORSWithOptions(opts CORSOptions) keelhttp.Middleware
- func DefaultJWTClaimsHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request, claims gojwt.Claims) bool
- func DefaultJWTClaimsProvider() gojwt.Claims
- func DefaultJWTErrorHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request, err error) bool
- func DefaultJWTInvalidTokenHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request, token *gojwt.Token) bool
- func DefaultJWTMissingTokenHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request) (gojwt.Claims, bool)
- func DefaultSessionIDGenerator() string
- func DefaultTrackingIDGenerator() string
- func GZip(opts ...GZipOption) keelhttp.Middleware
- func GZipWithOptions(opts GZipOptions) keelhttp.Middleware
- func JWT(v *jwt.JWT, contextKey any, opts ...JWTOption) keelhttp.Middleware
- func JWTWithOptions(v *jwt.JWT, contextKey any, opts JWTOptions) keelhttp.Middleware
- func Logger(opts ...LoggerOption) keelhttp.Middleware
- func LoggerWithOptions(opts LoggerOptions) keelhttp.Middleware
- func PoweredByHeader(opts ...PoweredByHeaderOption) keelhttp.Middleware
- func PoweredByHeaderWithOptions(opts PoweredByHeaderOptions) keelhttp.Middleware
- func RBAC(m *rbac.Matcher, extract rbac.RolesExtractor) keelhttp.Middleware
- func Recover(opts ...RecoverOption) keelhttp.Middleware
- func RecoverWithOptions(opts RecoverOptions) keelhttp.Middleware
- func Referer(opts ...RefererOption) keelhttp.Middleware
- func RefererWithOptions(opts RefererOptions) keelhttp.Middleware
- func RequestID(opts ...RequestIDOption) keelhttp.Middleware
- func RequestIDWithOptions(opts RequestIDOptions) keelhttp.Middleware
- func RequiredJWTMissingTokenHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request) (gojwt.Claims, bool)
- func ResponseTime(opts ...ResponseTimeOption) keelhttp.Middleware
- func ResponseTimeWithOptions(opts ResponseTimeOptions) keelhttp.Middleware
- func ServerHeader(opts ...ServerHeaderOption) keelhttp.Middleware
- func ServerHeaderWithOptions(opts ServerHeaderOptions) keelhttp.Middleware
- func SessionID(opts ...SessionIDOption) keelhttp.Middleware
- func SessionIDFromContext(ctx context.Context) string
- func SessionIDWithOptions(opts SessionIDOptions) keelhttp.Middleware
- func Skip(mw keelhttp.Middleware, skippers ...Skipper) keelhttp.Middleware
- func Telemetry(opts ...TelemetryOption) keelhttp.Middleware
- func TelemetryWithOptions(opts TelemetryOptions) keelhttp.Middleware
- func TokenAuth(token string, opts ...TokenAuthOption) keelhttp.Middleware
- func TokenAuthWithOptions(token string, opts TokenAuthOptions) keelhttp.Middleware
- func TrackingID(opts ...TrackingIDOption) keelhttp.Middleware
- func TrackingIDFromContext(ctx context.Context) string
- func TrackingIDWithOptions(opts TrackingIDOptions) keelhttp.Middleware
- func WrapResponseWriter(w http.ResponseWriter) *responseWriter
- type BasicAuthOption
- type BasicAuthOptions
- type CORSOption
- type CORSOptions
- type CookieTokenProviderOption
- type CookieTokenProviderOptions
- type GZipOption
- type GZipOptions
- type HeaderTokenProviderOption
- type HeaderTokenProviderOptions
- type JWTClaimsHandler
- type JWTClaimsProvider
- type JWTErrorHandler
- type JWTInvalidTokenHandler
- type JWTMissingTokenHandler
- type JWTOption
- func JWTWithClaimsHandler(v JWTClaimsHandler) JWTOption
- func JWTWithClaimsProvider(v JWTClaimsProvider) JWTOption
- func JWTWithErrorHandler(v JWTErrorHandler) JWTOption
- func JWTWithInvalidTokenHandler(v JWTInvalidTokenHandler) JWTOption
- func JWTWithMissingTokenHandler(v JWTMissingTokenHandler) JWTOption
- func JWTWithSetContext(v bool) JWTOption
- func JWTWithTokenProvider(v TokenProvider) JWTOption
- type JWTOptions
- type LoggerOption
- type LoggerOptions
- type PoweredByHeaderOption
- type PoweredByHeaderOptions
- type RecoverOption
- type RecoverOptions
- type RefererOption
- type RefererOptions
- type RequestIDOption
- func RequestIDWithGenerator(v provider.RequestID) RequestIDOption
- func RequestIDWithRequestHeader(v ...string) RequestIDOption
- func RequestIDWithResponseHeader(v string) RequestIDOption
- func RequestIDWithSetContext(v bool) RequestIDOption
- func RequestIDWithSetRequestHeader(v bool) RequestIDOption
- func RequestIDWithSetResponseHeader(v bool) RequestIDOption
- type RequestIDOptions
- type ResponseTimeOption
- type ResponseTimeOptions
- type ServerHeaderOption
- type ServerHeaderOptions
- type SessionIDGenerator
- type SessionIDOption
- func SessionIDWithCookie(v cookie.Cookie) SessionIDOption
- func SessionIDWithGenerator(v SessionIDGenerator) SessionIDOption
- func SessionIDWithHeader(v string) SessionIDOption
- func SessionIDWithSetContext(v bool) SessionIDOption
- func SessionIDWithSetCookie(v bool) SessionIDOption
- func SessionIDWithSetHeader(v bool) SessionIDOption
- type SessionIDOptions
- type Skipper
- type TelemetryOption
- type TelemetryOptions
- type TokenAuthOption
- type TokenAuthOptions
- type TokenProvider
- type TrackingIDGenerator
- type TrackingIDOption
- func TrackingIDWithCookie(v cookie.Cookie) TrackingIDOption
- func TrackingIDWithGenerator(v TrackingIDGenerator) TrackingIDOption
- func TrackingIDWithHeader(v string) TrackingIDOption
- func TrackingIDWithSetContext(v bool) TrackingIDOption
- func TrackingIDWithSetCookie(v bool) TrackingIDOption
- func TrackingIDWithSetHeader(v bool) TrackingIDOption
- type TrackingIDOptions
Examples ¶
Constants ¶
const (
DefaultSessionIDCookieName = "keel-session"
)
const (
DefaultTrackingIDCookieName = "keel-tracking"
)
Variables ¶
var DefaultGZipOptions = GZipOptions{ CompressionLevel: gzip.DefaultCompression, MinSize: 1024, }
Functions ¶
func BasicAuth ¶
func BasicAuth(username string, passwordHash []byte, opts ...BasicAuthOption) keelhttp.Middleware
BasicAuth middleware
func BasicAuthWithOptions ¶ added in v0.2.0
func BasicAuthWithOptions(username string, passwordHash []byte, opts BasicAuthOptions) keelhttp.Middleware
BasicAuthWithOptions middleware
func CORSWithOptions ¶ added in v0.2.0
func CORSWithOptions(opts CORSOptions) keelhttp.Middleware
CORSWithOptions middleware
func DefaultJWTClaimsHandler ¶ added in v0.12.0
func DefaultJWTClaimsHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request, claims gojwt.Claims) bool
DefaultJWTClaimsHandler function
func DefaultJWTClaimsProvider ¶ added in v0.2.0
DefaultJWTClaimsProvider function
func DefaultJWTErrorHandler ¶ added in v0.2.0
DefaultJWTErrorHandler function
func DefaultJWTInvalidTokenHandler ¶ added in v0.2.0
func DefaultJWTInvalidTokenHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request, token *gojwt.Token) bool
DefaultJWTInvalidTokenHandler function
func DefaultJWTMissingTokenHandler ¶ added in v0.2.0
func DefaultJWTMissingTokenHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request) (gojwt.Claims, bool)
DefaultJWTMissingTokenHandler function
func DefaultSessionIDGenerator ¶ added in v0.2.0
func DefaultSessionIDGenerator() string
DefaultSessionIDGenerator function
func DefaultTrackingIDGenerator ¶ added in v0.9.1
func DefaultTrackingIDGenerator() string
DefaultTrackingIDGenerator function
func GZipWithOptions ¶ added in v0.19.0
func GZipWithOptions(opts GZipOptions) keelhttp.Middleware
GZipWithOptions middleware
func JWTWithOptions ¶ added in v0.2.0
func JWTWithOptions(v *jwt.JWT, contextKey any, opts JWTOptions) keelhttp.Middleware
JWTWithOptions middleware
func Logger ¶
func Logger(opts ...LoggerOption) keelhttp.Middleware
Logger middleware
Example ¶
package main
import (
"fmt"
"net/http"
"github.com/foomo/keel/keeltest"
"github.com/foomo/keel/log"
"github.com/foomo/keel/net/http/middleware"
)
func main() {
svr := keeltest.NewExampleServer()
// get logger
l := svr.Logger()
// create demo service
svs := http.NewServeMux()
svs.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
fmt.Println("ok")
})
svr.AddService(
keeltest.NewServiceHTTP(l, "demo", svs,
middleware.Logger(),
),
)
svr.Start()
resp, err := http.Get(svr.GetService("demo").URL() + "/") //nolint:noctx
log.Must(l, err)
defer resp.Body.Close()
}
Output: ok
func LoggerWithOptions ¶ added in v0.2.0
func LoggerWithOptions(opts LoggerOptions) keelhttp.Middleware
LoggerWithOptions middleware
func PoweredByHeader ¶ added in v0.2.6
func PoweredByHeader(opts ...PoweredByHeaderOption) keelhttp.Middleware
PoweredByHeader middleware
func PoweredByHeaderWithOptions ¶ added in v0.2.6
func PoweredByHeaderWithOptions(opts PoweredByHeaderOptions) keelhttp.Middleware
PoweredByHeaderWithOptions middleware
func RBAC ¶ added in v0.26.0
func RBAC(m *rbac.Matcher, extract rbac.RolesExtractor) keelhttp.Middleware
RBAC middleware: a generic, path-based HTTP RBAC gate.
The middleware is transport-agnostic: only r.URL.Path and the caller-supplied roles drive the decision. It has no knowledge of any specific identity model — callers provide both the roles extractor and the configuration.
Typical wiring:
cfg, err := middleware.LoadRBACConfigFromFile("/etc/rbac.yaml")
keellog.Must(l, err, "load rbac config")
matcher, err := middleware.NewRBACMatcher(cfg)
keellog.Must(l, err, "compile rbac config")
mw := middleware.RBAC(matcher, extractRoles)
m and extract must be non-nil; they encode the decision contract and the middleware does not validate them per request.
Rule semantics: a request passes iff it hits no DenyRoles entry AND either the rule has no AllowRoles entries or roles intersect the AllowRoles set. Path matching picks the most specific rule (exact wins over longest matching prefix).
Denied requests log a structured zap warning ("rbac denied request") at WarnLevel with path, outcome, authenticated flag, roles, and matched rule path; allowed requests are not logged. The 401/403 split follows the extractor's authenticated flag: unauthenticated → 401, authenticated-but-disallowed → 403.
func RecoverWithOptions ¶ added in v0.2.0
func RecoverWithOptions(opts RecoverOptions) keelhttp.Middleware
RecoverWithOptions middleware
func Referer ¶ added in v0.14.2
func Referer(opts ...RefererOption) keelhttp.Middleware
Referer middleware
func RefererWithOptions ¶ added in v0.14.2
func RefererWithOptions(opts RefererOptions) keelhttp.Middleware
RefererWithOptions middleware
func RequestIDWithOptions ¶ added in v0.2.0
func RequestIDWithOptions(opts RequestIDOptions) keelhttp.Middleware
RequestIDWithOptions middleware
func RequiredJWTMissingTokenHandler ¶ added in v0.2.0
func RequiredJWTMissingTokenHandler(l *zap.Logger, w http.ResponseWriter, r *http.Request) (gojwt.Claims, bool)
RequiredJWTMissingTokenHandler function
func ResponseTime ¶ added in v0.2.0
func ResponseTime(opts ...ResponseTimeOption) keelhttp.Middleware
ResponseTime middleware
func ResponseTimeWithOptions ¶ added in v0.2.0
func ResponseTimeWithOptions(opts ResponseTimeOptions) keelhttp.Middleware
ResponseTimeWithOptions middleware
func ServerHeader ¶ added in v0.2.6
func ServerHeader(opts ...ServerHeaderOption) keelhttp.Middleware
ServerHeader middleware
func ServerHeaderWithOptions ¶ added in v0.2.6
func ServerHeaderWithOptions(opts ServerHeaderOptions) keelhttp.Middleware
ServerHeaderWithOptions middleware
func SessionID ¶ added in v0.2.0
func SessionID(opts ...SessionIDOption) keelhttp.Middleware
SessionID middleware
func SessionIDFromContext ¶ added in v0.2.0
SessionIDFromContext helper
func SessionIDWithOptions ¶ added in v0.2.0
func SessionIDWithOptions(opts SessionIDOptions) keelhttp.Middleware
SessionIDWithOptions middleware
func Skip ¶ added in v0.2.0
func Skip(mw keelhttp.Middleware, skippers ...Skipper) keelhttp.Middleware
func TelemetryWithOptions ¶ added in v0.2.0
func TelemetryWithOptions(opts TelemetryOptions) keelhttp.Middleware
TelemetryWithOptions middleware
func TokenAuth ¶ added in v0.2.0
func TokenAuth(token string, opts ...TokenAuthOption) keelhttp.Middleware
TokenAuth middleware
func TokenAuthWithOptions ¶ added in v0.2.0
func TokenAuthWithOptions(token string, opts TokenAuthOptions) keelhttp.Middleware
TokenAuthWithOptions middleware
func TrackingID ¶ added in v0.9.1
func TrackingID(opts ...TrackingIDOption) keelhttp.Middleware
TrackingID middleware
func TrackingIDFromContext ¶ added in v0.9.1
TrackingIDFromContext helper
func TrackingIDWithOptions ¶ added in v0.9.1
func TrackingIDWithOptions(opts TrackingIDOptions) keelhttp.Middleware
TrackingIDWithOptions middleware
func WrapResponseWriter ¶ added in v0.2.0
func WrapResponseWriter(w http.ResponseWriter) *responseWriter
Types ¶
type BasicAuthOption ¶ added in v0.2.0
type BasicAuthOption func(*BasicAuthOptions)
func BasicAuthWithRealm ¶ added in v0.2.0
func BasicAuthWithRealm(v string) BasicAuthOption
BasicAuthWithRealm middleware option
type BasicAuthOptions ¶ added in v0.2.0
type BasicAuthOptions struct {
Realm string
}
func GetDefaultBasicAuthOptions ¶ added in v0.2.0
func GetDefaultBasicAuthOptions() BasicAuthOptions
GetDefaultBasicAuthOptions returns the default options
type CORSOption ¶ added in v0.2.0
type CORSOption func(*CORSOptions)
func CORSWithAllowCredentials ¶ added in v0.2.0
func CORSWithAllowCredentials(v bool) CORSOption
CORSWithAllowCredentials middleware option
func CORSWithAllowHeaders ¶ added in v0.2.0
func CORSWithAllowHeaders(v ...string) CORSOption
CORSWithAllowHeaders middleware option
func CORSWithAllowMethods ¶ added in v0.2.0
func CORSWithAllowMethods(v ...string) CORSOption
CORSWithAllowMethods middleware option
func CORSWithAllowOrigins ¶ added in v0.2.0
func CORSWithAllowOrigins(v ...string) CORSOption
CORSWithAllowOrigins middleware option
func CORSWithExposeHeaders ¶ added in v0.2.0
func CORSWithExposeHeaders(v ...string) CORSOption
CORSWithExposeHeaders middleware option
func CORSWithMaxAge ¶ added in v0.2.0
func CORSWithMaxAge(v int) CORSOption
CORSWithMaxAge middleware option
type CORSOptions ¶ added in v0.2.0
type CORSOptions struct {
AllowOrigins []string
AllowMethods []string
AllowHeaders []string
AllowCredentials bool
ExposeHeaders []string
MaxAge int
}
func GetDefaultCORSOptions ¶ added in v0.2.0
func GetDefaultCORSOptions() CORSOptions
GetDefaultCORSOptions returns the default options
type CookieTokenProviderOption ¶ added in v0.2.0
type CookieTokenProviderOption func(*CookieTokenProviderOptions)
type CookieTokenProviderOptions ¶ added in v0.2.0
type CookieTokenProviderOptions struct{}
func GetDefaultCookieTokenOptions ¶ added in v0.2.0
func GetDefaultCookieTokenOptions() CookieTokenProviderOptions
GetDefaultCookieTokenOptions returns the default options
type GZipOption ¶ added in v0.19.0
type GZipOption func(*GZipOptions)
func GZipWithLevel ¶ added in v0.19.0
func GZipWithLevel(v int) GZipOption
GZipWithLevel allows setting a specific compression level for gzip (default: gzip.DefaultCompression).
func GZipWithMinSize ¶ added in v0.19.0
func GZipWithMinSize(v int) GZipOption
GZipWithMinSize allows setting a minimum response body length to apply gzip compression (default: 1400 bytes).
type GZipOptions ¶ added in v0.19.0
type HeaderTokenProviderOption ¶ added in v0.2.0
type HeaderTokenProviderOption func(*HeaderTokenProviderOptions)
func HeaderTokenProviderWithHeader ¶ added in v0.2.0
func HeaderTokenProviderWithHeader(v string) HeaderTokenProviderOption
HeaderTokenProviderWithHeader middleware option
func HeaderTokenProviderWithPrefix ¶ added in v0.2.0
func HeaderTokenProviderWithPrefix(v string) HeaderTokenProviderOption
HeaderTokenProviderWithPrefix middleware option
type HeaderTokenProviderOptions ¶ added in v0.2.0
func GetDefaultHeaderTokenOptions ¶ added in v0.2.0
func GetDefaultHeaderTokenOptions() HeaderTokenProviderOptions
GetDefaultHeaderTokenOptions returns the default options
type JWTClaimsHandler ¶ added in v0.12.0
type JWTClaimsProvider ¶ added in v0.2.0
type JWTErrorHandler ¶ added in v0.2.0
type JWTInvalidTokenHandler ¶ added in v0.2.0
type JWTMissingTokenHandler ¶ added in v0.2.0
type JWTOption ¶ added in v0.2.0
type JWTOption func(*JWTOptions)
func JWTWithClaimsHandler ¶ added in v0.12.0
func JWTWithClaimsHandler(v JWTClaimsHandler) JWTOption
JWTWithClaimsHandler middleware option
func JWTWithClaimsProvider ¶ added in v0.2.0
func JWTWithClaimsProvider(v JWTClaimsProvider) JWTOption
JWTWithClaimsProvider middleware option
func JWTWithErrorHandler ¶ added in v0.2.0
func JWTWithErrorHandler(v JWTErrorHandler) JWTOption
JWTWithErrorHandler middleware option
func JWTWithInvalidTokenHandler ¶ added in v0.2.0
func JWTWithInvalidTokenHandler(v JWTInvalidTokenHandler) JWTOption
JWTWithInvalidTokenHandler middleware option
func JWTWithMissingTokenHandler ¶ added in v0.2.0
func JWTWithMissingTokenHandler(v JWTMissingTokenHandler) JWTOption
JWTWithMissingTokenHandler middleware option
func JWTWithSetContext ¶ added in v0.2.1
func JWTWithTokenProvider ¶ added in v0.2.0
func JWTWithTokenProvider(v TokenProvider) JWTOption
JWTWithTokenProvider middleware option
type JWTOptions ¶ added in v0.2.0
type JWTOptions struct {
SetContext bool
TokenProvider TokenProvider
ClaimsProvider JWTClaimsProvider
ClaimsHandler JWTClaimsHandler
MissingTokenHandler JWTMissingTokenHandler
InvalidTokenHandler JWTInvalidTokenHandler
ErrorHandler JWTErrorHandler
}
func GetDefaultJWTOptions ¶ added in v0.2.0
func GetDefaultJWTOptions() JWTOptions
GetDefaultJWTOptions returns the default options
type LoggerOption ¶ added in v0.2.0
type LoggerOption func(*LoggerOptions)
func LoggerWithInjectLabeler ¶ added in v0.14.0
func LoggerWithInjectLabeler(v bool) LoggerOption
LoggerWithInjectLabeler middleware option
Example ¶
package main
import (
"fmt"
"net/http"
"github.com/foomo/keel/keeltest"
"github.com/foomo/keel/log"
httplog "github.com/foomo/keel/net/http/log"
"github.com/foomo/keel/net/http/middleware"
"go.uber.org/zap"
)
func main() {
svr := keeltest.NewExampleServer()
// get logger
l := svr.Logger()
// create demo service
svs := http.NewServeMux()
svs.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
fmt.Println("ok")
})
svr.AddService(
keeltest.NewServiceHTTP(l, "demo", svs,
func(l *zap.Logger, s string, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if labeler, ok := httplog.LabelerFromRequest(r); ok {
labeler.Add(zap.String("injected", "message"))
}
next.ServeHTTP(w, r)
})
},
middleware.Logger(
middleware.LoggerWithInjectLabeler(true),
),
),
)
svr.Start()
resp, err := http.Get(svr.GetService("demo").URL() + "/") //nolint:noctx
log.Must(l, err)
defer resp.Body.Close()
}
Output: ok
func LoggerWithMessage ¶ added in v0.2.4
func LoggerWithMessage(v string) LoggerOption
LoggerWithMessage middleware option
func LoggerWithMinErrorCode ¶ added in v0.11.6
func LoggerWithMinErrorCode(v int) LoggerOption
LoggerWithMinErrorCode middleware option
func LoggerWithMinWarnCode ¶ added in v0.11.6
func LoggerWithMinWarnCode(v int) LoggerOption
LoggerWithMinWarnCode middleware option
type LoggerOptions ¶ added in v0.2.0
func GetDefaultLoggerOptions ¶ added in v0.2.0
func GetDefaultLoggerOptions() LoggerOptions
GetDefaultLoggerOptions returns the default options
type PoweredByHeaderOption ¶ added in v0.2.6
type PoweredByHeaderOption func(*PoweredByHeaderOptions)
func PoweredByHeaderWithHeader ¶ added in v0.2.6
func PoweredByHeaderWithHeader(v string) PoweredByHeaderOption
PoweredByHeaderWithHeader middleware option
func PoweredByHeaderWithMessage ¶ added in v0.2.6
func PoweredByHeaderWithMessage(v string) PoweredByHeaderOption
PoweredByHeaderWithMessage middleware option
type PoweredByHeaderOptions ¶ added in v0.2.6
func GetDefaultPoweredByHeaderOptions ¶ added in v0.2.6
func GetDefaultPoweredByHeaderOptions() PoweredByHeaderOptions
GetDefaultPoweredByHeaderOptions returns the default options
type RecoverOption ¶ added in v0.2.0
type RecoverOption func(*RecoverOptions)
func RecoverWithDisablePrintStack ¶ added in v0.2.0
func RecoverWithDisablePrintStack(v bool) RecoverOption
RecoverWithDisablePrintStack middleware option
type RecoverOptions ¶ added in v0.2.0
type RecoverOptions struct {
DisablePrintStack bool
}
func GetDefaultRecoverOptions ¶ added in v0.2.0
func GetDefaultRecoverOptions() RecoverOptions
GetDefaultRecoverOptions returns the default options
type RefererOption ¶ added in v0.14.2
type RefererOption func(*RefererOptions)
func RefererWithRequestHeader ¶ added in v0.14.2
func RefererWithRequestHeader(v ...string) RefererOption
RefererWithRequestHeader middleware option
func RefererWithSetContext ¶ added in v0.14.2
func RefererWithSetContext(v bool) RefererOption
RefererWithSetContext middleware option
type RefererOptions ¶ added in v0.14.2
func GetDefaultRefererOptions ¶ added in v0.14.2
func GetDefaultRefererOptions() RefererOptions
GetDefaultRefererOptions returns the default options
type RequestIDOption ¶ added in v0.2.0
type RequestIDOption func(*RequestIDOptions)
func RequestIDWithGenerator ¶ added in v0.2.0
func RequestIDWithGenerator(v provider.RequestID) RequestIDOption
RequestIDWithGenerator middleware option
func RequestIDWithRequestHeader ¶ added in v0.11.3
func RequestIDWithRequestHeader(v ...string) RequestIDOption
RequestIDWithRequestHeader middleware option
func RequestIDWithResponseHeader ¶ added in v0.2.0
func RequestIDWithResponseHeader(v string) RequestIDOption
RequestIDWithResponseHeader middleware option
func RequestIDWithSetContext ¶ added in v0.11.3
func RequestIDWithSetContext(v bool) RequestIDOption
RequestIDWithSetContext middleware option
func RequestIDWithSetRequestHeader ¶ added in v0.11.3
func RequestIDWithSetRequestHeader(v bool) RequestIDOption
RequestIDWithSetRequestHeader middleware option
func RequestIDWithSetResponseHeader ¶ added in v0.2.0
func RequestIDWithSetResponseHeader(v bool) RequestIDOption
RequestIDWithSetResponseHeader middleware option
type RequestIDOptions ¶ added in v0.2.0
type RequestIDOptions struct {
Provider provider.RequestID
RequestHeader []string
ResponseHeader string
SetRequestHeader bool
SetResponseHeader bool
SetContext bool
}
func GetDefaultRequestIDOptions ¶ added in v0.2.0
func GetDefaultRequestIDOptions() RequestIDOptions
GetDefaultRequestIDOptions returns the default options
type ResponseTimeOption ¶ added in v0.2.0
type ResponseTimeOption func(*ResponseTimeOptions)
func ResponseTimeWithMaxDuration ¶ added in v0.2.0
func ResponseTimeWithMaxDuration(v time.Duration) ResponseTimeOption
ResponseTimeWithMaxDuration middleware option
func ResponseTimeWithMaxDurationMessage ¶ added in v0.2.0
func ResponseTimeWithMaxDurationMessage(v string) ResponseTimeOption
ResponseTimeWithMaxDurationMessage middleware option
func ResponseTimeWithSetHeader ¶ added in v0.2.0
func ResponseTimeWithSetHeader(v bool) ResponseTimeOption
ResponseTimeWithSetHeader middleware option
type ResponseTimeOptions ¶ added in v0.2.0
type ResponseTimeOptions struct {
SetHeader bool
MaxDuration time.Duration
MaxDurationMessage string
}
func GetDefaultResponseTimeOptions ¶ added in v0.2.0
func GetDefaultResponseTimeOptions() ResponseTimeOptions
GetDefaultResponseTimeOptions returns the default options
type ServerHeaderOption ¶ added in v0.2.6
type ServerHeaderOption func(*ServerHeaderOptions)
func ServerHeaderWithHeader ¶ added in v0.2.6
func ServerHeaderWithHeader(v string) ServerHeaderOption
ServerHeaderWithHeader middleware option
func ServerHeaderWithName ¶ added in v0.2.6
func ServerHeaderWithName(v string) ServerHeaderOption
ServerHeaderWithName middleware option
type ServerHeaderOptions ¶ added in v0.2.6
func GetDefaultServerHeaderOptions ¶ added in v0.2.6
func GetDefaultServerHeaderOptions() ServerHeaderOptions
GetDefaultServerHeaderOptions returns the default options
type SessionIDGenerator ¶ added in v0.2.0
type SessionIDGenerator func() string
type SessionIDOption ¶ added in v0.2.0
type SessionIDOption func(*SessionIDOptions)
func SessionIDWithCookie ¶ added in v0.2.0
func SessionIDWithCookie(v cookie.Cookie) SessionIDOption
SessionIDWithCookie middleware option
func SessionIDWithGenerator ¶ added in v0.2.0
func SessionIDWithGenerator(v SessionIDGenerator) SessionIDOption
SessionIDWithGenerator middleware option
func SessionIDWithHeader ¶ added in v0.2.0
func SessionIDWithHeader(v string) SessionIDOption
func SessionIDWithSetContext ¶ added in v0.2.0
func SessionIDWithSetContext(v bool) SessionIDOption
SessionIDWithSetContext middleware option
func SessionIDWithSetCookie ¶ added in v0.2.0
func SessionIDWithSetCookie(v bool) SessionIDOption
SessionIDWithSetCookie middleware option
func SessionIDWithSetHeader ¶ added in v0.2.0
func SessionIDWithSetHeader(v bool) SessionIDOption
SessionIDWithSetHeader middleware option
type SessionIDOptions ¶ added in v0.2.0
type SessionIDOptions struct {
// Header to look up the session id
Header string
// Cookie how to set the cookie
Cookie cookie.Cookie
// Generator for the session ids
Generator SessionIDGenerator
// SetCookie if true it will create a cookie if not exists
SetCookie bool
// SetHeader if true it will set add a request header
SetHeader bool
// SetContext if true it will set the context key
SetContext bool
}
func GetDefaultSessionIDOptions ¶ added in v0.2.0
func GetDefaultSessionIDOptions() SessionIDOptions
GetDefaultSessionIDOptions returns the default options
type Skipper ¶ added in v0.2.0
func RequestURIBlacklistSkipper ¶ added in v0.2.0
RequestURIBlacklistSkipper returns a HTTPMiddlewareConfig.Skipper which skips the given uris
func RequestURIWhitelistSkipper ¶ added in v0.2.0
RequestURIWhitelistSkipper returns a HTTPMiddlewareConfig.Skipper which skips all but the given uris
type TelemetryOption ¶ added in v0.2.0
type TelemetryOption func(*TelemetryOptions)
func TelemetryWithInjectPropagationHeader ¶ added in v0.9.12
func TelemetryWithInjectPropagationHeader(v bool) TelemetryOption
func TelemetryWithName ¶ added in v0.2.6
func TelemetryWithName(v string) TelemetryOption
func TelemetryWithOtelOpts ¶ added in v0.2.6
func TelemetryWithOtelOpts(v ...otelhttp.Option) TelemetryOption
TelemetryWithOtelOpts middleware options
type TelemetryOptions ¶ added in v0.2.0
type TelemetryOptions struct {
Name string
OtelOpts []otelhttp.Option
InjectPropagationHeader bool
}
func GetDefaultTelemetryOptions ¶ added in v0.2.0
func GetDefaultTelemetryOptions() TelemetryOptions
GetDefaultTelemetryOptions returns the default options
type TokenAuthOption ¶ added in v0.2.0
type TokenAuthOption func(*TokenAuthOptions)
func TokenAuthWithTokenProvider ¶ added in v0.2.0
func TokenAuthWithTokenProvider(v TokenProvider) TokenAuthOption
TokenAuthWithTokenProvider middleware option
type TokenAuthOptions ¶ added in v0.2.0
type TokenAuthOptions struct {
// TokenProvider function to retrieve the token
TokenProvider TokenProvider
}
func GetDefaultTokenAuthOptions ¶ added in v0.2.0
func GetDefaultTokenAuthOptions() TokenAuthOptions
GetDefaultTokenAuthOptions returns the default options
type TokenProvider ¶ added in v0.2.0
func CookieTokenProvider ¶ added in v0.2.0
func CookieTokenProvider(cookieName string, opts ...CookieTokenProviderOption) TokenProvider
func HeaderTokenProvider ¶ added in v0.2.0
func HeaderTokenProvider(opts ...HeaderTokenProviderOption) TokenProvider
type TrackingIDGenerator ¶ added in v0.9.1
type TrackingIDGenerator func() string
type TrackingIDOption ¶ added in v0.9.1
type TrackingIDOption func(*TrackingIDOptions)
func TrackingIDWithCookie ¶ added in v0.9.1
func TrackingIDWithCookie(v cookie.Cookie) TrackingIDOption
TrackingIDWithCookie middleware option
func TrackingIDWithGenerator ¶ added in v0.9.1
func TrackingIDWithGenerator(v TrackingIDGenerator) TrackingIDOption
TrackingIDWithGenerator middleware option
func TrackingIDWithHeader ¶ added in v0.9.1
func TrackingIDWithHeader(v string) TrackingIDOption
func TrackingIDWithSetContext ¶ added in v0.9.1
func TrackingIDWithSetContext(v bool) TrackingIDOption
TrackingIDWithSetContext middleware option
func TrackingIDWithSetCookie ¶ added in v0.9.1
func TrackingIDWithSetCookie(v bool) TrackingIDOption
TrackingIDWithSetCookie middleware option
func TrackingIDWithSetHeader ¶ added in v0.9.1
func TrackingIDWithSetHeader(v bool) TrackingIDOption
TrackingIDWithSetHeader middleware option
type TrackingIDOptions ¶ added in v0.9.1
type TrackingIDOptions struct {
// Header to look up the tracking id
Header string
// Cookie how to set the cookie
Cookie cookie.Cookie
// Generator for the tracking ids
Generator TrackingIDGenerator
// SetCookie if true it will create a cookie if not exists
SetCookie bool
// SetHeader if true it will set add a request header
SetHeader bool
// SetContext if true it will set the context key
SetContext bool
}
func GetDefaultTrackingIDOptions ¶ added in v0.9.1
func GetDefaultTrackingIDOptions() TrackingIDOptions
GetDefaultTrackingIDOptions returns the default options
Source Files
¶
- basicauth.go
- cookietokenprovider.go
- cors.go
- gzip.go
- headertokenprovider.go
- jwt.go
- logger.go
- poweredbyheader.go
- rbac.go
- recover.go
- referrer.go
- requestid.go
- requesturiblacklistskipper.go
- requesturiwhitelistskipper.go
- responsetime.go
- responsewriter.go
- serverheader.go
- sessionid.go
- skip.go
- skipper.go
- telemetry.go
- tokenauth.go
- tokenprovider.go
- trackingid.go