filter

package
v2.5.0-RC+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// UsingCachingValue using cached value to response
	UsingCachingValue = "__using_cache_value__"
)

Variables

This section is empty.

Functions

func NewCachedValue

func NewCachedValue(body, contentType []byte) []byte

NewCachedValue returns a cached value

func ParseCachedValue

func ParseCachedValue(data []byte) ([]byte, []byte)

ParseCachedValue returns cached value as content-type and body value

Types

type BaseFilter

type BaseFilter struct{}

BaseFilter base filter support default implemention

func (BaseFilter) Init

func (f BaseFilter) Init(cfg string) error

Init init filter

func (BaseFilter) Post

func (f BaseFilter) Post(c Context) (statusCode int, err error)

Post execute after proxy

func (BaseFilter) PostErr

func (f BaseFilter) PostErr(c Context)

PostErr execute proxy has errors

func (BaseFilter) Pre

func (f BaseFilter) Pre(c Context) (statusCode int, err error)

Pre execute before proxy

type Context

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

	OriginRequest() *fasthttp.RequestCtx
	ForwardRequest() *fasthttp.Request
	Response() *fasthttp.Response

	API() *metapb.API
	DispatchNode() *metapb.DispatchNode
	Server() *metapb.Server
	Analysis() *util.Analysis

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

Context filter context

type Filter

type Filter interface {
	Name() string
	Init(cfg string) error

	Pre(c Context) (statusCode int, err error)
	Post(c Context) (statusCode int, err error)
	PostErr(c Context)
}

Filter filter interface

Jump to

Keyboard shortcuts

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