Documentation ¶
Index ¶
- Constants
- Variables
- func SemicolonMiddleware() gin.HandlerFunc
- func SetAuthHandle(auth Authenticator)
- type Authenticator
- type CallQueue
- type Context
- type GroupRouteInfo
- type HttpProxy
- func (hp *HttpProxy) AddGroupRoute(groupName string, auth Authenticator, routes ...*GroupRouteInfo) error
- func (hp *HttpProxy) AddRoute(method string, path string, handle RouteHandle, auth Authenticator) error
- func (hp *HttpProxy) Init(option *Options) error
- func (hp *HttpProxy) IsResolved() bool
- func (hp *HttpProxy) OnRpcResponse(ret *protocol.ProxyRespPackage) error
- func (hp *HttpProxy) SetHttpRequestHandle(handle ProxyRequestHandle)
- func (hp *HttpProxy) ShutDown()
- func (hp *HttpProxy) Start() error
- func (hp *HttpProxy) Tick()
- type Option
- type Options
- type ProxyRequestHandle
- type ProxyWriter
- type Response
- type RouteHandle
Constants ¶
View Source
const ( StatusClosed = iota //服务已经关闭 StatusResolved //服务正在运行 StatusUpdating //服务正在更新 StatusClosing //服务正在关闭 )
Variables ¶
View Source
var ( ErrInvalidHttpAddress = errors.New("invalid http address ") ErrNoEffectiveServicePath = errors.New("no effective service config path ") ErrInitServiceDBError = errors.New("create service data base error ") ErrRequestNotFound = errors.New("http call info not found ") ErrRequestExpired = errors.New("the http request has expired ") ErrRoutePathExist = errors.New("route path already exists") ErrCertificateNotExist = errors.New("certificate file does not exist") )
Functions ¶
func SemicolonMiddleware ¶
func SemicolonMiddleware() gin.HandlerFunc
func SetAuthHandle ¶
func SetAuthHandle(auth Authenticator)
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context http_proxy 上下文,对外屏蔽内部使用的框架, 便于框架内部迭代而不影响外部api
func (*Context) GetRawData ¶
type GroupRouteInfo ¶ added in v0.4.19
type GroupRouteInfo struct { Method string // method type, GET POST PUT Path string //API 路径 Handle RouteHandle //处理函数 }
GroupRouteInfo 添加GroupAPI
type HttpProxy ¶
type HttpProxy struct {
// contains filtered or unexported fields
}
HttpProxy http 代理,启动http服务器,将收到http 转化为 plato rpc协议
func MakeHttpProxy ¶
func (*HttpProxy) AddGroupRoute ¶ added in v0.4.19
func (hp *HttpProxy) AddGroupRoute(groupName string, auth Authenticator, routes ...*GroupRouteInfo) error
AddGroupRoute 添加自定义groupName, 使用auth 函数对组内所有 handle api进行鉴权, 鉴权函数可以为空
func (*HttpProxy) AddRoute ¶ added in v0.4.19
func (hp *HttpProxy) AddRoute(method string, path string, handle RouteHandle, auth Authenticator) error
AddRoute 添加自定义的API路径path, 执行函数handle, 以及是否需要使用auth 进行鉴权,鉴权函数可以为空
func (*HttpProxy) OnRpcResponse ¶
func (hp *HttpProxy) OnRpcResponse(ret *protocol.ProxyRespPackage) error
func (*HttpProxy) SetHttpRequestHandle ¶
func (hp *HttpProxy) SetHttpRequestHandle(handle ProxyRequestHandle)
type Options ¶
type Options struct { Address string `yaml:"address"` //监听地址 Auth string `yaml:"auth"` //鉴权类型,留空不开启鉴权 ServicePath string `yaml:"service_path"` //服务配置路径 Mode string `yaml:"mode"` // 运行模式 debug release ShutdownTimeout uint32 `yaml:"shutdown_timeout"` //停机超时时间, 单位毫秒 CacheSize uint32 `yaml:"cache_size"` // 命令排队数量,默认是1024,框架处理速率是每秒 5000 条命令左右 不应该有太多堆积 SSLKey string `yaml:"ssl_key"` // https 私聊 SSLPem string `yaml:"ssl_pem"` // https 证书 // contains filtered or unexported fields }
Options http proxy 模块配置
type ProxyRequestHandle ¶
type ProxyRequestHandle func(req *protocol.ProxyRequestPackage) (uint32, error)
ProxyRequestHandle http 请求转换为rpc 请求后回调函数 成功返回 call id 和 nil 错误; 失败 则返回0 和具体错误
type ProxyWriter ¶
type ProxyWriter struct {
// contains filtered or unexported fields
}
ProxyWriter 日志包装器
type RouteHandle ¶
RouteHandle 自定义 api 方法处理原型,在独立协程中运行
Click to show internal directories.
Click to hide internal directories.