engine

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterOrder0 = iota

	FilterOrderCloseConnection
	FilterOrderLoadUpstreamHead
	FilterOrderFindHandler
	FilterOrderInvokeHandler

	FilterOrder99
)

定义各个过滤器的处理顺序

Variables

This section is empty.

Functions

func HandleError

func HandleError(err error)

HandleError ...

func HandleErrorX

func HandleErrorX(x any)

HandleErrorX ...

Types

type Context

type Context struct {
	Engine     *Engine
	Handler    Handler
	Selector   tbmp.HandlerSelector
	Connection tbmp.ServerSideConnection
	Upstream   tbmp.Upstream
	Downstream tbmp.Downstream
}

Context ...

func (*Context) Send

func (inst *Context) Send(status int, contentType string) error

Send 发送下行数据流的头部

type ElementOnInit

type ElementOnInit func(e *Engine) error

ElementOnInit ...

type ElementRegistration

type ElementRegistration struct {
	Enabled bool

	OnInit func(e *Engine) error
}

ElementRegistration ...

type ElementRegistry

type ElementRegistry interface {
	Elements() []*ElementRegistration
}

ElementRegistry ...

type Engine

type Engine struct {
	Handlers []*HandlerRegistration
	Filters  []*FilterRegistration
	Elements []*ElementRegistration
	Chain    FilterChain
}

Engine ...

type Filter

type Filter interface {
	DoFilter(c *Context, next FilterChain) error
}

Filter ...

type FilterChain

type FilterChain interface {
	DoFilter(c *Context) error
}

FilterChain ...

type FilterChainBuilder

type FilterChainBuilder struct {
	// contains filtered or unexported fields
}

FilterChainBuilder ...

func (*FilterChainBuilder) AddRegistrations

func (inst *FilterChainBuilder) AddRegistrations(src ...*FilterRegistration) *FilterChainBuilder

AddRegistrations ...

func (*FilterChainBuilder) AddRegistries

func (inst *FilterChainBuilder) AddRegistries(src ...FilterRegistry) *FilterChainBuilder

AddRegistries ...

func (*FilterChainBuilder) Create

func (inst *FilterChainBuilder) Create() FilterChain

Create ...

type FilterRegistration

type FilterRegistration struct {
	Enabled bool
	Order   int
	Filter  Filter
}

FilterRegistration ...

type FilterRegistry

type FilterRegistry interface {
	Filters() []*FilterRegistration
}

FilterRegistry ...

type Handler

type Handler func(c *Context) error

Handler ...

type HandlerRegistration

type HandlerRegistration struct {
	Method  string // for selector
	Path    string // for selector
	Enabled bool
	Handler Handler
}

HandlerRegistration ...

func (*HandlerRegistration) GetSelector

func (inst *HandlerRegistration) GetSelector() tbmp.HandlerSelector

GetSelector ...

type HandlerRegistry

type HandlerRegistry interface {
	Handlers() []*HandlerRegistration
}

HandlerRegistry ...

Jump to

Keyboard shortcuts

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