Versions in this module Expand all Collapse all v1 v1.0.4 Sep 29, 2024 Changes in this version + const AccessLoggerNameVarKey + const ClientIPVarKey + const ConnCtxKey + const DefaultHTTPPort + const DefaultHTTPSPort + const ErrorCtxKey + const ExtraLogFieldsCtxKey + const LogSkipVar + const MatcherErrorVarKey + const MatcherNameCtxKey + const OriginalRequestCtxKey + const ServerCtxKey + const TrustedProxyVarKey + const VarsCtxKey + var CELTypeJSON = cel.MapType(cel.StringType, cel.DynType) + var ErrNotImplemented = fmt.Errorf("method not implemented") + func CELMatcherDecorator(funcName string, fac CELMatcherFactory) interpreter.InterpretableDecorator + func CELMatcherImpl(macroName, funcName string, matcherDataTypes []*cel.Type, ...) (cel.Library, error) + func CELMatcherRuntimeFunction(funcName string, fac CELMatcherFactory) functions.BinaryOp + func CELValueToMapStrList(data ref.Val) (map[string][]string, error) + func CIDRExpressionToPrefix(expr string) (netip.Prefix, error) + func CleanPath(p string, collapseSlashes bool) string + func GetVar(ctx context.Context, key string) any + func NewMatcherCELLibrary(envOptions []cel.EnvOption, programOptions []cel.ProgramOption) cel.Library + func NewTestReplacer(req *http.Request) *kengine.Replacer + func ParseKenginefileNestedMatcherSet(d *kenginefile.Dispenser) (kengine.ModuleMap, error) + func ParseNamedResponseMatcher(d *kenginefile.Dispenser, matchers map[string]ResponseMatcher) error + func PrepareRequest(r *http.Request, repl *kengine.Replacer, w http.ResponseWriter, s *Server) *http.Request + func PrivateRangesCIDR() []string + func RegisterNetworkHTTP3(originalNetwork, h3Network string) + func SanitizedPathJoin(root, reqPath string) string + func SetVar(ctx context.Context, key string, value any) + func StatusCodeMatches(actual, configured int) bool + type App struct + GracePeriod kengine.Duration + HTTPPort int + HTTPSPort int + Servers map[string]*Server + ShutdownDelay kengine.Duration + func (App) KengineModule() kengine.ModuleInfo + func (app *App) Provision(ctx kengine.Context) error + func (app *App) Start() error + func (app *App) Stop() error + func (app *App) Validate() error + type AutoHTTPSConfig struct + DisableCerts bool + DisableRedir bool + Disabled bool + IgnoreLoadedCerts bool + Skip []string + SkipCerts []string + type CELLibraryProducer interface + CELLibrary func(kengine.Context) (cel.Library, error) + type CELMatcherFactory func(data ref.Val) (RequestMatcher, error) + type ExtraLogFields struct + func (e *ExtraLogFields) Add(field zap.Field) + func (e *ExtraLogFields) Set(field zap.Field) + type HTTPErrorConfig struct + Routes RouteList + func (*HTTPErrorConfig) WithError(r *http.Request, err error) *http.Request + type HTTPRedirectListenerWrapper struct + MaxHeaderBytes int64 + func (HTTPRedirectListenerWrapper) KengineModule() kengine.ModuleInfo + func (h *HTTPRedirectListenerWrapper) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (h *HTTPRedirectListenerWrapper) WrapListener(l net.Listener) net.Listener + type Handler interface + ServeHTTP func(http.ResponseWriter, *http.Request) error + type HandlerError struct + Err error + ID string + StatusCode int + Trace string + func Error(statusCode int, err error) HandlerError + func (e HandlerError) Error() string + func (e HandlerError) Unwrap() error + type HandlerFunc func(http.ResponseWriter, *http.Request) error + func (f HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) error + type IPRangeSource interface + GetIPRanges func(*http.Request) []netip.Prefix + type Invoke struct + Name string + func (Invoke) KengineModule() kengine.ModuleInfo + func (invoke *Invoke) ServeHTTP(w http.ResponseWriter, r *http.Request, next Handler) error + type LoggableHTTPHeader struct + ShouldLogCredentials bool + func (h LoggableHTTPHeader) MarshalLogObject(enc zapcore.ObjectEncoder) error + type LoggableHTTPRequest struct + ShouldLogCredentials bool + func (r LoggableHTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error + type LoggableStringArray []string + func (sa LoggableStringArray) MarshalLogArray(enc zapcore.ArrayEncoder) error + type LoggableTLSConnState tls.ConnectionState + func (t LoggableTLSConnState) MarshalLogObject(enc zapcore.ObjectEncoder) error + type MatchClientIP struct + Ranges []string + func (MatchClientIP) CELLibrary(ctx kengine.Context) (cel.Library, error) + func (MatchClientIP) KengineModule() kengine.ModuleInfo + func (m *MatchClientIP) Provision(ctx kengine.Context) error + func (m *MatchClientIP) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchClientIP) Match(r *http.Request) bool + type MatchExpression struct + Expr string + Name string + func (MatchExpression) KengineModule() kengine.ModuleInfo + func (m *MatchExpression) Provision(ctx kengine.Context) error + func (m *MatchExpression) UnmarshalJSON(data []byte) error + func (m *MatchExpression) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchExpression) MarshalJSON() ([]byte, error) + func (m MatchExpression) Match(r *http.Request) bool + type MatchHeader http.Header + func (MatchHeader) CELLibrary(_ kengine.Context) (cel.Library, error) + func (MatchHeader) KengineModule() kengine.ModuleInfo + func (m *MatchHeader) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchHeader) Match(r *http.Request) bool + type MatchHeaderRE map[string]*MatchRegexp + func (MatchHeaderRE) CELLibrary(ctx kengine.Context) (cel.Library, error) + func (MatchHeaderRE) KengineModule() kengine.ModuleInfo + func (m *MatchHeaderRE) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchHeaderRE) Match(r *http.Request) bool + func (m MatchHeaderRE) Provision(ctx kengine.Context) error + func (m MatchHeaderRE) Validate() error + type MatchHost []string + func (MatchHost) CELLibrary(ctx kengine.Context) (cel.Library, error) + func (MatchHost) KengineModule() kengine.ModuleInfo + func (m *MatchHost) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchHost) Match(r *http.Request) bool + func (m MatchHost) Provision(_ kengine.Context) error + type MatchMethod []string + func (MatchMethod) CELLibrary(_ kengine.Context) (cel.Library, error) + func (MatchMethod) KengineModule() kengine.ModuleInfo + func (m *MatchMethod) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchMethod) Match(r *http.Request) bool + type MatchNot struct + MatcherSets []MatcherSet + MatcherSetsRaw []kengine.ModuleMap + func (MatchNot) KengineModule() kengine.ModuleInfo + func (m *MatchNot) Provision(ctx kengine.Context) error + func (m *MatchNot) UnmarshalJSON(data []byte) error + func (m *MatchNot) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchNot) MarshalJSON() ([]byte, error) + func (m MatchNot) Match(r *http.Request) bool + type MatchPath []string + func (MatchPath) CELLibrary(ctx kengine.Context) (cel.Library, error) + func (MatchPath) KengineModule() kengine.ModuleInfo + func (m *MatchPath) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchPath) Match(r *http.Request) bool + func (m MatchPath) Provision(_ kengine.Context) error + type MatchPathRE struct + func (MatchPathRE) CELLibrary(ctx kengine.Context) (cel.Library, error) + func (MatchPathRE) KengineModule() kengine.ModuleInfo + func (m MatchPathRE) Match(r *http.Request) bool + type MatchProtocol string + func (MatchProtocol) CELLibrary(_ kengine.Context) (cel.Library, error) + func (MatchProtocol) KengineModule() kengine.ModuleInfo + func (m *MatchProtocol) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchProtocol) Match(r *http.Request) bool + type MatchQuery url.Values + func (MatchQuery) CELLibrary(_ kengine.Context) (cel.Library, error) + func (MatchQuery) KengineModule() kengine.ModuleInfo + func (m *MatchQuery) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchQuery) Match(r *http.Request) bool + type MatchRegexp struct + Name string + Pattern string + func (mre *MatchRegexp) Match(input string, repl *kengine.Replacer) bool + func (mre *MatchRegexp) Provision(kengine.Context) error + func (mre *MatchRegexp) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (mre *MatchRegexp) Validate() error + type MatchRemoteIP struct + Ranges []string + func (MatchRemoteIP) CELLibrary(ctx kengine.Context) (cel.Library, error) + func (MatchRemoteIP) KengineModule() kengine.ModuleInfo + func (m *MatchRemoteIP) Provision(ctx kengine.Context) error + func (m *MatchRemoteIP) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchRemoteIP) Match(r *http.Request) bool + type MatchTLS struct + HandshakeComplete *bool + func (MatchTLS) KengineModule() kengine.ModuleInfo + func (m *MatchTLS) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchTLS) Match(r *http.Request) bool + type MatchVarsRE map[string]*MatchRegexp + func (MatchVarsRE) KengineModule() kengine.ModuleInfo + func (m *MatchVarsRE) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m MatchVarsRE) Match(r *http.Request) bool + func (m MatchVarsRE) Provision(ctx kengine.Context) error + func (m MatchVarsRE) Validate() error + type MatcherSet []RequestMatcher + func (mset MatcherSet) Match(r *http.Request) bool + type MatcherSets []MatcherSet + func (ms *MatcherSets) FromInterface(matcherSets any) error + func (ms MatcherSets) AnyMatch(req *http.Request) bool + func (ms MatcherSets) String() string + type Metrics struct + type Middleware func(Handler) Handler + type MiddlewareHandler interface + ServeHTTP func(http.ResponseWriter, *http.Request, Handler) error + type RawMatcherSets []kengine.ModuleMap + type RequestMatcher interface + Match func(*http.Request) bool + type ResponseHandler struct + Match *ResponseMatcher + Routes RouteList + StatusCode WeakString + func (rh *ResponseHandler) Provision(ctx kengine.Context) error + type ResponseMatcher struct + Headers http.Header + StatusCode []int + func (rm ResponseMatcher) Match(statusCode int, hdr http.Header) bool + type ResponseRecorder interface + Buffer func() *bytes.Buffer + Buffered func() bool + Size func() int + Status func() int + WriteResponse func() error + func NewResponseRecorder(w http.ResponseWriter, buf *bytes.Buffer, shouldBuffer ShouldBufferFunc) ResponseRecorder + type ResponseWriterWrapper struct + func (rww *ResponseWriterWrapper) Push(target string, opts *http.PushOptions) error + func (rww *ResponseWriterWrapper) ReadFrom(r io.Reader) (n int64, err error) + func (rww *ResponseWriterWrapper) Unwrap() http.ResponseWriter + type Route struct + Group string + Handlers []MiddlewareHandler + HandlersRaw []json.RawMessage + MatcherSets MatcherSets + MatcherSetsRaw RawMatcherSets + Terminal bool + func (r *Route) Provision(ctx kengine.Context, metrics *Metrics) error + func (r *Route) ProvisionHandlers(ctx kengine.Context, metrics *Metrics) error + func (r *Route) ProvisionMatchers(ctx kengine.Context) error + func (r Route) Compile(next Handler) Handler + func (r Route) Empty() bool + func (r Route) String() string + type RouteList []Route + func (routes RouteList) Compile(next Handler) Handler + func (routes RouteList) Provision(ctx kengine.Context) error + func (routes RouteList) ProvisionHandlers(ctx kengine.Context, metrics *Metrics) error + func (routes RouteList) ProvisionMatchers(ctx kengine.Context) error + type Server struct + AutoHTTPS *AutoHTTPSConfig + ClientIPHeaders []string + EnableFullDuplex bool + Errors *HTTPErrorConfig + IdleTimeout kengine.Duration + KeepAliveInterval kengine.Duration + Listen []string + ListenerWrappersRaw []json.RawMessage + Logs *ServerLogConfig + MaxHeaderBytes int + Metrics *Metrics + NamedRoutes map[string]*Route + Protocols []string + ReadHeaderTimeout kengine.Duration + ReadTimeout kengine.Duration + Routes RouteList + StrictSNIHost *bool + TLSConnPolicies kenginetls.ConnectionPolicies + TrustedProxiesRaw json.RawMessage + TrustedProxiesStrict int + WriteTimeout kengine.Duration + func (s *Server) Listeners() []net.Listener + func (s *Server) Name() string + func (s *Server) RegisterConnContext(f func(ctx context.Context, c net.Conn) context.Context) + func (s *Server) RegisterConnState(f func(net.Conn, http.ConnState)) + func (s *Server) RegisterOnShutdown(f func()) + func (s *Server) RegisterOnStop(f func(context.Context) error) + func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) + type ServerLogConfig struct + DefaultLoggerName string + LoggerNames map[string]StringArray + ShouldLogCredentials bool + SkipHosts []string + SkipUnmappedHosts bool + Trace bool + type ShouldBufferFunc func(status int, header http.Header) bool + type StaticError struct + Error string + StatusCode WeakString + func (StaticError) KengineModule() kengine.ModuleInfo + func (e *StaticError) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (e StaticError) ServeHTTP(w http.ResponseWriter, r *http.Request, _ Handler) error + type StaticIPRange struct + Ranges []string + func (StaticIPRange) KengineModule() kengine.ModuleInfo + func (m *StaticIPRange) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (s *StaticIPRange) GetIPRanges(_ *http.Request) []netip.Prefix + func (s *StaticIPRange) Provision(ctx kengine.Context) error + type StaticResponse struct + Abort bool + Body string + Close bool + Headers http.Header + StatusCode WeakString + func (StaticResponse) KengineModule() kengine.ModuleInfo + func (s *StaticResponse) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (s StaticResponse) ServeHTTP(w http.ResponseWriter, r *http.Request, next Handler) error + type StringArray []string + func (sa *StringArray) UnmarshalJSON(b []byte) error + type Subroute struct + Errors *HTTPErrorConfig + Routes RouteList + func (Subroute) KengineModule() kengine.ModuleInfo + func (sr *Subroute) Provision(ctx kengine.Context) error + func (sr *Subroute) ServeHTTP(w http.ResponseWriter, r *http.Request, next Handler) error + type VarsMatcher map[string][]string + func (VarsMatcher) KengineModule() kengine.ModuleInfo + func (m *VarsMatcher) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m VarsMatcher) Match(r *http.Request) bool + type VarsMiddleware map[string]any + func (VarsMiddleware) KengineModule() kengine.ModuleInfo + func (m *VarsMiddleware) UnmarshalKenginefile(d *kenginefile.Dispenser) error + func (m VarsMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next Handler) error + type WeakString string + func (ws *WeakString) UnmarshalJSON(b []byte) error + func (ws WeakString) Bool() bool + func (ws WeakString) Float64() float64 + func (ws WeakString) Int() int + func (ws WeakString) MarshalJSON() ([]byte, error) + func (ws WeakString) String() string Other modules containing this package github.com/khulnasoft/kengine/v2