 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- Variables
- func AddRequestHook(hook *RequestHook)
- func CallRequestAfterHook(req *Request, writer *ResponseWriter) (goNext bool)
- func CallRequestBeforeHook(req *Request, writer *ResponseWriter) (goNext bool)
- type ClientPool
- type Listener
- func (this *Listener) ApplyServer(server *teaconfigs.ServerConfig)
- func (this *Listener) HasServer(serverId string) bool
- func (this *Listener) HasServers() bool
- func (this *Listener) Reload() error
- func (this *Listener) RemoveServer(serverId string)
- func (this *Listener) Reset()
- func (this *Listener) Shutdown() error
- func (this *Listener) Start() error
 
- type Manager
- func (this *Manager) ApplyServer(server *teaconfigs.ServerConfig)
- func (this *Manager) FindServer(serverId string) *teaconfigs.ServerConfig
- func (this *Manager) FindServerErrors(serverId string) []string
- func (this *Manager) Reload() error
- func (this *Manager) RemoveServer(serverId string)
- func (this *Manager) Restart() error
- func (this *Manager) Shutdown() error
- func (this *Manager) Start() error
- func (this *Manager) Wait()
 
- type NamedServer
- type Request
- func (this *Request) CachePolicy() *shared.CachePolicy
- func (this *Request) Format(source string) string
- func (this *Request) IsCacheEnabled() bool
- func (this *Request) IsWatching() bool
- func (this *Request) Raw() *http.Request
- func (this *Request) SetAttr(key string, value string)
- func (this *Request) SetCacheEnabled()
- func (this *Request) SetCachePolicy(config *shared.CachePolicy)
- func (this *Request) SetHost(host string)
- func (this *Request) SetIsWatching(isWatching bool)
- func (this *Request) SetURI(uri string)
- func (this *Request) SetVarMapping(varName string, varValue string)
- func (this *Request) WriteResponseHeaders(writer *ResponseWriter, statusCode int)
 
- type RequestHook
- type ResponseWriter
- func (this *ResponseWriter) AddHeaders(header http.Header)
- func (this *ResponseWriter) Body() []byte
- func (this *ResponseWriter) BodyIsCopying() bool
- func (this *ResponseWriter) Close()
- func (this *ResponseWriter) Gzip(level uint8, minLength int64)
- func (this *ResponseWriter) Header() http.Header
- func (this *ResponseWriter) HeaderData() []byte
- func (this *ResponseWriter) Prepare(size int64)
- func (this *ResponseWriter) Raw() http.ResponseWriter
- func (this *ResponseWriter) SentBodyBytes() int64
- func (this *ResponseWriter) SetBodyCopying(b bool)
- func (this *ResponseWriter) StatusCode() int
- func (this *ResponseWriter) Write(data []byte) (n int, err error)
- func (this *ResponseWriter) WriteHeader(statusCode int)
 
- type Scheme
- type StaticDelivery
- type StaticFileCache
- type Tunnel
- type TunnelConnection
- type TunnelManager
- type TunnelResponseBody
Constants ¶
      View Source
      
  
const ( SchemeHTTP = Scheme(1) SchemeHTTPS = Scheme(2) )
Variables ¶
      View Source
      
  var QPS = int32(0)
    对外可读取的QPS
公用的静态文件分发器
客户端池单例
共享的管理对象
      View Source
      
  var StatusCodeParser func(statusCode int, headers http.Header, respData []byte, parserScript string) (string, error) = nil
    状态码筛选
Functions ¶
func CallRequestAfterHook ¶
func CallRequestAfterHook(req *Request, writer *ResponseWriter) (goNext bool)
执行After Hook
func CallRequestBeforeHook ¶
func CallRequestBeforeHook(req *Request, writer *ResponseWriter) (goNext bool)
执行Before Hook
Types ¶
type Listener ¶
type Listener struct {
	IsChanged bool // 标记是否改变,用来在其他地方重启改变的监听器
	Scheme  Scheme // http & https
	Address string
	Error   error
	// contains filtered or unexported fields
}
    代理服务监听器
func (*Listener) ApplyServer ¶ added in v0.1.2
func (this *Listener) ApplyServer(server *teaconfigs.ServerConfig)
应用配置
func (*Listener) RemoveServer ¶ added in v0.1.2
删除配置
type Manager ¶ added in v0.1.2
type Manager struct {
	// contains filtered or unexported fields
}
    管理器
func (*Manager) ApplyServer ¶ added in v0.1.2
func (this *Manager) ApplyServer(server *teaconfigs.ServerConfig)
添加Server
func (*Manager) FindServer ¶ added in v0.1.2
func (this *Manager) FindServer(serverId string) *teaconfigs.ServerConfig
查找Server
func (*Manager) FindServerErrors ¶ added in v0.1.2
查找Server相关错误
func (*Manager) RemoveServer ¶ added in v0.1.2
删除Server
type NamedServer ¶ added in v0.1.2
type NamedServer struct {
	Name   string                   // 匹配后的域名
	Server *teaconfigs.ServerConfig // 匹配后的服务配置
}
    域名和服务映射
type Request ¶
type Request struct {
	// contains filtered or unexported fields
}
    请求定义 HTTP HEADER RFC: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
func (*Request) CachePolicy ¶
func (this *Request) CachePolicy() *shared.CachePolicy
func (*Request) SetCacheEnabled ¶
func (this *Request) SetCacheEnabled()
func (*Request) SetCachePolicy ¶
func (this *Request) SetCachePolicy(config *shared.CachePolicy)
func (*Request) SetVarMapping ¶ added in v0.1.5
添加自定义变量
func (*Request) WriteResponseHeaders ¶ added in v0.1.5
func (this *Request) WriteResponseHeaders(writer *ResponseWriter, statusCode int)
输出自定义Response Header
type RequestHook ¶
type RequestHook struct {
	BeforeRequest func(req *Request, writer *ResponseWriter) (goNext bool)
	AfterRequest  func(req *Request, writer *ResponseWriter) (goNext bool)
}
    请求Hook定义
type ResponseWriter ¶
type ResponseWriter struct {
	// contains filtered or unexported fields
}
    响应Writer
func NewResponseWriter ¶
func NewResponseWriter(httpResponseWriter http.ResponseWriter) *ResponseWriter
包装对象
func (*ResponseWriter) AddHeaders ¶
func (this *ResponseWriter) AddHeaders(header http.Header)
添加一组Header
func (*ResponseWriter) BodyIsCopying ¶
func (this *ResponseWriter) BodyIsCopying() bool
判断是否在拷贝Body数据
func (*ResponseWriter) SetBodyCopying ¶
func (this *ResponseWriter) SetBodyCopying(b bool)
设置拷贝Body数据
type StaticDelivery ¶ added in v0.1.2
type StaticDelivery struct {
	// contains filtered or unexported fields
}
    静态文件分发器
type StaticFileCache ¶ added in v0.1.2
type StaticFileCache struct {
	// contains filtered or unexported fields
}
    静态文件缓存
type Tunnel ¶ added in v0.1.5
type Tunnel struct {
	// contains filtered or unexported fields
}
    隧道状态管理
type TunnelConnection ¶ added in v0.1.5
type TunnelConnection struct {
	// contains filtered or unexported fields
}
    隧道连接
func NewTunnelConnection ¶ added in v0.1.5
func NewTunnelConnection(conn net.Conn) *TunnelConnection
获取新对象
type TunnelManager ¶ added in v0.1.5
type TunnelManager struct {
	// contains filtered or unexported fields
}
    Tunnel管理器
func (*TunnelManager) FindTunnel ¶ added in v0.1.5
func (this *TunnelManager) FindTunnel(serverId, tunnelId string) *Tunnel
查找Tunnel
func (*TunnelManager) OnAttach ¶ added in v0.1.5
func (this *TunnelManager) OnAttach(server *teaconfigs.ServerConfig)
加载
func (*TunnelManager) OnDetach ¶ added in v0.1.5
func (this *TunnelManager) OnDetach(server *teaconfigs.ServerConfig)
卸载
type TunnelResponseBody ¶ added in v0.1.5
type TunnelResponseBody struct {
	io.ReadCloser
	// contains filtered or unexported fields
}
    Tunnel响应包装,主要是为了覆盖Close()方法
       Source Files
      ¶
      Source Files
      ¶
    
- client.go
- init.go
- listener.go
- manager.go
- named_server.go
- request.go
- request_backend.go
- request_fastcgi.go
- request_hook.go
- request_page.go
- request_proxy.go
- request_redirect_https.go
- request_rewrite.go
- request_root.go
- request_shutdown.go
- request_tunnel.go
- request_url.go
- request_waf.go
- request_websocket.go
- response.go
- static_delivery.go
- tunnel.go
- tunnel_connection.go
- tunnel_manager.go
- tunnel_response_body.go
 Click to show internal directories. 
   Click to hide internal directories.