filter

package
v0.0.0-...-4ac4421 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2018 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// FilteredPassed request can pass to server
	FilteredPassed = 0
	// FilteredFailed request cannot pass to server
	FilteredFailed = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseAuth

type BaseAuth interface {
	LimitReached() bool
}

type CircuitBreakerFilter

type CircuitBreakerFilter struct {
	DefaultFilter
	CBreaker *cbreaker.Circuits
}

CircuitBreakerFilter circuit-breaker filter

func (*CircuitBreakerFilter) AsBegin

func (c *CircuitBreakerFilter) AsBegin(ctx Context) Response

AsBegin execute at the beginning

func (*CircuitBreakerFilter) AsEnd

func (c *CircuitBreakerFilter) AsEnd(ctx Context) Response

AsEnd execute at the end

func (*CircuitBreakerFilter) Init

func (c *CircuitBreakerFilter) Init(config string) error

Init filter initialization

func (*CircuitBreakerFilter) Name

func (c *CircuitBreakerFilter) Name() string

Name returns CircuitBreakerFilter's name

type Context

type Context interface {
	StartAt() time.Time
	EndAt() time.Time

	SetAttr(key string, value interface{})
	GetAttr(key string) interface{}

	HTTPRequest() *http.Request
}

Context filter context interface

func NewContext

func NewContext(req *http.Request) Context

NewContext NewContext

type CookieAuth

type CookieAuth interface {
	BaseAuth
	IsCookieValid() bool
}

type DefaultFilter

type DefaultFilter struct{}

DefaultFilter base filter

func (*DefaultFilter) AsBegin

func (f *DefaultFilter) AsBegin(c Context) Response

AsBegin execute at the beginning

func (*DefaultFilter) AsEnd

func (f *DefaultFilter) AsEnd(c Context) Response

AsEnd execute at the end

func (*DefaultFilter) Init

func (f *DefaultFilter) Init() error

Init filter initialization

func (*DefaultFilter) Name

func (f *DefaultFilter) Name() string

Name filter's name

type Filter

type Filter interface {
	Name() string
	Init(config string) error
	AsBegin(c Context) Response
	AsEnd(c Context) Response
}

Filter base filter interface

type HeaderAuth

type HeaderAuth interface {
	BaseAuth
	IsCrossDomain() bool
}

type HeaderFilter

type HeaderFilter struct {
	DefaultFilter
	// contains filtered or unexported fields
}

HeaderFilter rate-limiting filter

func (*HeaderFilter) AsBegin

func (f *HeaderFilter) AsBegin(c Context) Response

AsBegin execute at the beginning

func (*HeaderFilter) AsEnd

func (f *HeaderFilter) AsEnd(c Context) Response

AsEnd execute at the end

func (*HeaderFilter) Init

func (f *HeaderFilter) Init(config string) error

Init filter initialization

func (*HeaderFilter) Name

func (f *HeaderFilter) Name() string

Name returns HeaderFilter's name

type RateLimitFilter

type RateLimitFilter struct {
	DefaultFilter
	// contains filtered or unexported fields
}

RateLimitFilter rate-limiting filter

func (*RateLimitFilter) AsBegin

func (f *RateLimitFilter) AsBegin(c Context) Response

AsBegin execute at the beginning

func (*RateLimitFilter) AsEnd

func (f *RateLimitFilter) AsEnd(c Context) Response

AsEnd execute at the end

func (*RateLimitFilter) Init

func (f *RateLimitFilter) Init(config string) error

Init filter initialization

func (*RateLimitFilter) Name

func (f *RateLimitFilter) Name() string

Name returns RateLimitFilter's name

type Response

type Response struct {
	Time    time.Time
	Code    int
	Message string
}

Response filter response

type TimeUsedFilter

type TimeUsedFilter struct {
	DefaultFilter
	// contains filtered or unexported fields
}

TimeUsedFilter rate-limiting filter

func (*TimeUsedFilter) AsBegin

func (f *TimeUsedFilter) AsBegin(c Context) Response

AsBegin execute at the beginning

func (*TimeUsedFilter) AsEnd

func (f *TimeUsedFilter) AsEnd(c Context) Response

AsEnd execute at the end

func (*TimeUsedFilter) Init

func (f *TimeUsedFilter) Init(config string) error

Init filter initialization

func (*TimeUsedFilter) Name

func (f *TimeUsedFilter) Name() string

Name returns TimeUsedFilter's name

Jump to

Keyboard shortcuts

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