xfilter

package
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConstructor

func NewConstructor(o ...Option) func(http.Handler) http.Handler

NewConstructor returns an Alice-style decorator that filters requests sent to the decorated handler. If no filters are configured, the returned constructor simply returns the handler unmodified.

Types

type Func

type Func func(*http.Request) error

Func is the function equivalent of Interface

func (Func) Allow

func (f Func) Allow(r *http.Request) error

type Interface

type Interface interface {
	// Allow tests whether the given request is allowed to execute.  This method can return
	// errors that implement the go-kit interfaces, e.g. StatusCoder.
	Allow(*http.Request) error
}

Interface is essentially a predicate that determines whether a request is allowed.

func Allow

func Allow() Interface

Allow returns an xfilter that always returns a nil error

func Reject

func Reject(err error) Interface

Reject returns an xfilter that always returns the given error. If err == nil, this function is equivalent to Allow.

type Option

type Option func(*constructor)

Option is a configuration option for a filter constructor

func WithErrorEncoder

func WithErrorEncoder(ee gokithttp.ErrorEncoder) Option

func WithFilters

func WithFilters(f ...Interface) Option

Jump to

Keyboard shortcuts

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