filter

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(mux *RouteMux)

Init filter

func RegistryFilter

func RegistryFilter(filter Filter)

RegistryFilter register filter

Types

type Chain

type Chain struct {
	Filters  []Filter
	Index    int
	Exchange *Exchange
	Route    config.Route
}

Chain struct

func NewChain

func NewChain(resp http.ResponseWriter, req *http.Request, route config.Route) *Chain

NewChain new chain

func (*Chain) DoFilter

func (c *Chain) DoFilter()

DoFilter run filter

type Exchange

type Exchange struct {
	Resp      http.ResponseWriter
	Req       *http.Request
	Ctx       context.Context
	Attr      map[string]interface{}
	Err       error
	Completed bool
	Written   sync.Once
}

Exchange struct

func (*Exchange) Error

func (e *Exchange) Error(err error)

type Filter

type Filter interface {
	Init(mux *RouteMux)
	Name() string
	Filter(exchange *Exchange, c interface{}) error
}

Filter interface

type ProxyConfig

type ProxyConfig struct {
	URI string `asn1:"url"`
}

ProxyConfig struct

type ResourceConfig

type ResourceConfig struct {
	Root string
}

ResourceConfig struct

type RewriteConfig

type RewriteConfig struct {
	Regex       string
	Replacement string
}

RewriteConfig struct

type RouteMux added in v0.2.0

type RouteMux struct {
	Routes []config.Route
}

RouteMux struct

func NewRouteMux added in v0.2.0

func NewRouteMux(c *config.Config) *RouteMux

NewRouteMux new route mux

func (RouteMux) ServeHTTP added in v0.2.0

func (r RouteMux) ServeHTTP(resp http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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