Documentation ¶
Overview ¶
Package connector 实现了基本的连接器接口
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Connector ¶
type Connector interface { // Init 初始化连接器设置 Init() error // Run 运行(接受连接并进行处理,阻塞) Run() error // Stop 停止运行 Stop() error // Dispatcher 返回当前调度器 Dispatcher() Dispatcher // SetDispatcher 设置调度器 SetDispatcher(dispatcher Dispatcher) }
连接器
func NewHttpConnector ¶
NewHttpConnector 创建Http连接器
func NewHttpsConnector ¶
NewHttpsConnector 创建Http连接器
source:格式如: 127.0.0.1:8080;Cert=path/to/cert;Key=path/to/key
type Dispatcher ¶
type Dispatcher interface { // Dispatch 分发 // segments:用于进行分发的路径段信息 // data:连接携带的数据 Dispatch(segments []string, data interface{}) }
Dispatcher 调度器
type Error ¶
type Error string
错误信息
const ( ErrorInvalidConnectorCreator Error = "ErrorInvalidConnectorCreator(N10000):无效的连接创建器" ErrorInvalidKind Error = "ErrorInvalidKind(N10010):无效的连接类型(%s)" ErrorFailToStop Error = "ErrorFailToStop(N10020):无法停止连接器(%s)" ErrorInvalidDispatcher Error = "ErrorInvalidDispatcher(N10030):无效的Dispatcher,无法启动Connector(%s)" ErrorParamNotFound Error = "ErrorParamNotFound(N10100):source中没有%s,无法创建https连接器" )
错误码
type HttpConnector ¶
type HttpConnector struct {
// contains filtered or unexported fields
}
Http连接器
func (*HttpConnector) Dispatcher ¶
func (this *HttpConnector) Dispatcher() Dispatcher
Dispatcher 返回当前调度器
func (*HttpConnector) SetDispatcher ¶
func (this *HttpConnector) SetDispatcher(dispatcher Dispatcher)
SetDispatcher 设置调度器
type HttpContext ¶
type HttpContext struct { Request *http.Request //http请求 ResponseWriter http.ResponseWriter //http响应 }
Http上下文
type HttpHandler ¶
type HttpHandler struct {
// contains filtered or unexported fields
}
Http处理器
func (*HttpHandler) ServeHTTP ¶
func (this *HttpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)
ServeHTTP 处理http请求
type HttpsConnector ¶
type HttpsConnector struct { HttpConnector // contains filtered or unexported fields }
Https连接器
Click to show internal directories.
Click to hide internal directories.