router_http

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(port int, id string, config *Config) error

Add 将路由配置加入到路由管理器

func Del

func Del(port int, id string) error

Del 将路由配置从路由管理器中删去

Types

type Cert

type Cert struct {
	Crt string
	Key string
}

Cert 证书结构体

type Certs

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

Certs 证书集合结构体

func (*Certs) Get

func (c *Certs) Get(hostName string) (*tls.Certificate, bool)

Get 获取证书

type Config

type Config struct {
	ID   string
	Name string
	//Cert    []Cert
	Hosts   []string
	Methods []string
	Target  http_service.IChain
	Rules   []Rule
}

Config http路由实例配置结构体

type EndPoint

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

EndPoint 路由端点结构体

func NewEndPoint

func NewEndPoint(endpoint router.IEndPoint) *EndPoint

NewEndPoint 创建

func (*EndPoint) Header

func (e *EndPoint) Header(name string) (checker.Checker, bool)

Header 通过header的key返回对应指标值的checker

func (*EndPoint) Headers

func (e *EndPoint) Headers() []string

Headers 返回路由端点内header的指标key列表

func (*EndPoint) Location

func (e *EndPoint) Location() (checker.Checker, bool)

Location 返回location指标的checker

func (*EndPoint) Queries

func (e *EndPoint) Queries() []string

Queries 返回路由端点内query的指标key列表

func (*EndPoint) Query

func (e *EndPoint) Query(name string) (checker.Checker, bool)

Query 通过query的key返回对应指标值的checker

type HTTPRouterHelper

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

HTTPRouterHelper http路由指标类型排序helper

func NewHTTPRouterHelper

func NewHTTPRouterHelper() *HTTPRouterHelper

NewHTTPRouterHelper 新建一个http路由指标类型排序helper

func (*HTTPRouterHelper) Less

func (h *HTTPRouterHelper) Less(i, j string) bool

Less 排序指标类型的匹配顺序

type HTTPSources

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

HTTPSources 封装http请求的结构体

func (*HTTPSources) Get

func (h *HTTPSources) Get(cmd string) (string, bool)

Get 由传入的指标key来获取请求中的指标值

type HeaderItem

type HeaderItem struct {
	Name    string
	Pattern string
}

HeaderItem HeaderItem

type IMatcher

type IMatcher interface {
	Match(req http_service.IRequestReader) (service.IService, router.IEndPoint, bool)
}

IMatcher IMatcher接口实现了Match方法:根据http请求返回服务接口

type IRouter

type IRouter interface {
	SetRouter(id string, config *Config) error
	Count() int
	Del(id string) int
	Handler(ctx *fasthttp.RequestCtx)
}

IRouter 路由树的接口

type IRouters

type IRouters interface {
	Set(port int, id string, conf *Config) (IRouter, bool, error)
	Del(port int, id string) (IRouter, bool)
}

IRouters 路由树管理器实现的接口

type Manager

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

Manager 路由管理器结构体

func NewManager

func NewManager(tf traffic.ITraffic, listenCfg *config.ListensMsg, pluginManager plugin.IPluginManager) *Manager

NewManager 创建路由管理器

func (*Manager) Add

func (m *Manager) Add(port int, id string, config *Config) error

Add 新增路由配置到路由管理器中

func (*Manager) Cancel

func (m *Manager) Cancel()

Cancel 关闭路由管理器

func (*Manager) Del

func (m *Manager) Del(port int, id string) error

Del 将某个路由配置从路由管理器中删去

type Matcher

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

Matcher Matcher结构体,实现了根据请求返回服务接口的方法

func (*Matcher) Match

Match 对http请求进行路由匹配,并返回服务

type NotFond

type NotFond struct {
}

func (*NotFond) Destroy

func (n *NotFond) Destroy()

func (*NotFond) DoFilter

func (n *NotFond) DoFilter(ctx http_service.IHttpContext, chain http_service.IChain) (err error)

type QueryItem

type QueryItem struct {
	Name    string
	Pattern string
}

QueryItem QueryItem

type Router

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

Router 实现了路由树接口

func NewRouter

func NewRouter(routerFilter plugin.IPlugin) *Router

NewRouter 新建路由树

func (*Router) Count

func (r *Router) Count() int

Count 返回路由树中配置实例的数量

func (*Router) Del

func (r *Router) Del(id string) int

Del 将某个路由从路由树中删去

func (*Router) Handler

func (r *Router) Handler(requestCtx *fasthttp.RequestCtx)

Handler 路由树的handler方法

func (*Router) SetRouter

func (r *Router) SetRouter(id string, config *Config) error

SetRouter 将路由配置加入到路由树中

type Routers

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

Routers 路由树管理器的结构体

func NewRouters

func NewRouters(pluginManager plugin.IPluginManager) *Routers

NewRouters 新建路由树管理器

func (*Routers) Del

func (rs *Routers) Del(port int, id string) (IRouter, bool)

Del 将路由配置从对应端口的路由树中删去

func (*Routers) Set

func (rs *Routers) Set(port int, id string, conf *Config) (IRouter, bool, error)

Set 将路由配置加入到对应端口的路由树中

type Rule

type Rule struct {
	Location string
	Header   []HeaderItem
	Query    []QueryItem
}

Rule 路由Rule

Jump to

Keyboard shortcuts

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