http_router

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(register eosc.IExtenderDriverRegister)

Register 注册http路由驱动工厂

Types

type Cert

type Cert struct {
	Key string `json:"key"`
	Crt string `json:"crt"`
}

Cert http路由驱动配置证书Cert结构体

type Config

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

Config http路由配置结构体

type DisableHandler added in v0.6.0

type DisableHandler struct {
}

func (*DisableHandler) Destroy added in v0.6.0

func (d *DisableHandler) Destroy()

func (*DisableHandler) DoChain added in v0.6.0

func (d *DisableHandler) DoChain(ctx service.IHttpContext) error

type DriverConfig

type DriverConfig struct {
	Listen  int                       `json:"listen" yaml:"listen" title:"port" description:"使用端口" default:"80" label:"端口号" maximum:"65535"`
	Method  []string                  `json:"method" yaml:"method" enum:"GET,POST,PUT,DELETE,PATH,HEAD,OPTIONS" label:"请求方式"`
	Host    []string                  `json:"host" yaml:"host" label:"域名"`
	Rules   []DriverRule              `json:"rules" yaml:"rules" label:"路由规则"`
	Target  eosc.RequireId            `json:"target" yaml:"target" skill:"github.com/eolinker/apinto/service.service.IService" required:"true" label:"目标服务"`
	Disable bool                      `json:"disable" yaml:"disable" label:"禁用路由"`
	Plugins map[string]*plugin.Config `json:"plugins" yaml:"plugins" label:"插件配置"`
}

DriverConfig http路由驱动配置

type DriverRule

type DriverRule struct {
	Location string            `json:"location" yaml:"location"`
	Header   map[string]string `json:"header" yaml:"header" label:"请求头部(key:value类型)"`
	Query    map[string]string `json:"query" yaml:"query" label:"query参数(key:value类型)"`
}

DriverRule http路由驱动配置Rule结构体

type HTTPRouterDriver

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

HTTPRouterDriver 实现github.com/eolinker/eosc.eosc.IProfessionDriver接口

func NewHTTPRouter

func NewHTTPRouter() *HTTPRouterDriver

NewHTTPRouter 创建一个http路由驱动

func (*HTTPRouterDriver) ConfigType

func (h *HTTPRouterDriver) ConfigType() reflect.Type

ConfigType 返回http路由驱动配置的反射类型

func (*HTTPRouterDriver) Create

func (h *HTTPRouterDriver) Create(id, name string, v interface{}, workers map[eosc.RequireId]interface{}) (eosc.IWorker, error)

Create 创建一个http路由驱动实例

func (*HTTPRouterDriver) NewRouter

func (h *HTTPRouterDriver) NewRouter(id, name string, c *DriverConfig, target service.IServiceCreate) (*Router, error)

NewRouter 创建http路由驱动实例

type Router

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

Router http路由驱动实例结构体,实现了worker接口

func (*Router) CheckSkill

func (r *Router) CheckSkill(skill string) bool

CheckSkill 技能检查

func (*Router) Id

func (r *Router) Id() string

Id 返回workerID

func (*Router) Reset

func (r *Router) Reset(conf interface{}, workers map[eosc.RequireId]interface{}) error

func (*Router) Start

func (r *Router) Start() error

Start 启动路由worker,将路由实例加入到路由树中

func (*Router) Stop

func (r *Router) Stop() error

Stop 停止路由worker,将路由实例从路由树中删去

type RouterDriverFactory

type RouterDriverFactory struct {
}

RouterDriverFactory http路由驱动工厂结构体

func NewRouterDriverFactory

func NewRouterDriverFactory() *RouterDriverFactory

NewRouterDriverFactory 创建一个http路由驱动工厂

func (*RouterDriverFactory) Create

func (r *RouterDriverFactory) Create(profession string, name string, label string, desc string, params map[string]interface{}) (eosc.IExtenderDriver, error)

Create 创建http路由驱动

func (*RouterDriverFactory) Render added in v0.6.0

func (r *RouterDriverFactory) Render() interface{}

type RouterHandler

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

func NewDisableHandler added in v0.6.0

func NewDisableHandler(routerConfig *router_http.Config) *RouterHandler

func NewRouterHandler

func NewRouterHandler(routerConfig *router_http.Config, handler service2.IService) *RouterHandler

func (*RouterHandler) Destroy

func (r *RouterHandler) Destroy()

func (*RouterHandler) DoFilter

func (r *RouterHandler) DoFilter(ctx service.IHttpContext, next service.IChain) (err error)

Jump to

Keyboard shortcuts

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