Documentation ¶
Index ¶
- Constants
- Variables
- func CleanPath(p string) string
- func ListenAndServe(addr string, handler http.Handler) error
- func ListenAndServeTLS(addr string, certFile string, keyFile string, handler http.Handler) error
- func NewServer(addr string, handler http.Handler) (srv *endlessServer)
- type Api
- type Context
- type Count
- type Gateway
- type Goku
- type GokuServer
- type Handle
- type LimitRate
- func (l *LimitRate) DayLimit() bool
- func (l *LimitRate) GetCount() int
- func (l *LimitRate) HourLimit() bool
- func (l *LimitRate) IsNeedReset() bool
- func (l *LimitRate) MinLimit() bool
- func (l *LimitRate) SecLimit() bool
- func (l *LimitRate) SetRate(rate int, end int, rateType string)
- func (l *LimitRate) UpdateCurrentCount()
- func (l *LimitRate) UpdateDayCount()
- type Param
- type Params
- type Rate
- type Router
- func (r *Router) Handle(method, path string, handle Handle, context Context)
- func (r *Router) Lookup(method, path string) (Handle, Params, *Context, bool)
- func (r *Router) RegisterRouter(c conf.GlobalConfig, handle ...Handle)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(handle Handle)
- type Strategy
Constants ¶
const ( PRE_SIGNAL = iota POST_SIGNAL STATE_INIT STATE_RUNNING STATE_SHUTTING_DOWN STATE_TERMINATE )
Variables ¶
Functions ¶
func ListenAndServe ¶
ListenAndServe listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections. Handler is typically nil, in which case the DefaultServeMux is used.
func ListenAndServeTLS ¶
ListenAndServeTLS acts identically to ListenAndServe, except that it expects HTTPS connections. Additionally, files containing a certificate and matching private key for the server must be provided. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate followed by the CA's certificate.
Types ¶
type Api ¶
type Api struct { RequestURL string `json:"request_url" yaml:"request_url"` BackendPath string `json:"backend_path" yaml:"backend_path"` ProxyURL string `json:"proxy_url" yaml:"proxy_url"` ProxyMethod string `json:"proxy_method" yaml:"proxy_method"` IsRaw bool `json:"is_raw" yaml:"is_raw"` ProxyParams []conf.Param `json:"proxy_params" yaml:"proxy_params"` ConstantParams []conf.ConstantParam `json:"constant_params" yaml:"constant_params"` Follow bool `json:"follow" yaml:"follow"` }
type Gateway ¶
type Gateway struct { GatewayAlias string `json:"gateway_alias" yaml:"gateway_alias"` GatewayStatus string `json:"gateway_status" yaml:"gateway_status"` IPLimitType string `json:"ip_limit_type" yaml:"ip_limit_type"` IPWhiteList []string `json:"ip_white_list" yaml:"ip_white_list"` IPBlackList []string `json:"ip_black_list" yaml:"ip_black_list"` }
type Goku ¶
type Goku struct { *Router ServiceConfig conf.GlobalConfig // contains filtered or unexported fields }
func (*Goku) SetListener ¶
type GokuServer ¶
type LimitRate ¶
type LimitRate struct {
// contains filtered or unexported fields
}
LimitRate 限速
func (*LimitRate) UpdateCurrentCount ¶
func (l *LimitRate) UpdateCurrentCount()
func (*LimitRate) UpdateDayCount ¶
func (l *LimitRate) UpdateDayCount()
type Router ¶
type Router struct { RedirectTrailingSlash bool RedirectFixedPath bool HandleMethodNotAllowed bool HandleOPTIONS bool NotFound http.Handler MethodNotAllowed http.Handler PanicHandler func(http.ResponseWriter, *http.Request, interface{}) // contains filtered or unexported fields }
Router是一个可以被用来调度请求去不同处理函数的Handler
func (*Router) Lookup ¶
查找允许手动查找方法 + 路径组合。 这对于构建围绕此路由器的框架非常有用。 如果找到路径, 它将返回句柄函数和路径参数值 否则, 第三个返回值指示是否应执行与附加/不带尾随斜线的同一路径的重定向
func (*Router) RegisterRouter ¶
func (r *Router) RegisterRouter(c conf.GlobalConfig, handle ...Handle)
注册路由
type Strategy ¶
type Strategy struct { StrategyID string `json:"strategy_id" yaml:"strategy_id"` Auth string `json:"auth" yaml:"auth"` BasicUserName string `json:"basic_user_name" yaml:"basic_user_name"` BasicUserPassword string `json:"basic_user_password" yaml:"basic_user_password"` ApiKey string `json:"api_key" yaml:"api_key"` IPLimitType string `json:"ip_limit_type" yaml:"ip_limit_type"` IPWhiteList []string `json:"ip_white_list" yaml:"ip_white_list"` IPBlackList []string `json:"ip_black_list" yaml:"ip_black_list"` RateLimitList []conf.RateLimitInfo `json:"rate_limit_list" yaml:"rate_limit_list"` }