Documentation ¶
Index ¶
- Constants
- Variables
- func ContextReplacer(h echo.HandlerFunc) echo.HandlerFunc
- func Error(msg string)
- func Errorf(fmt string, args ...interface{})
- func Shutdown()
- type Auth
- type CircuitBreakAt
- type Config
- type Context
- type FwdItem
- func (s *FwdItem) Balancer() (bal middleware.ProxyBalancer)
- func (s *FwdItem) BalancerIsEmpty() bool
- func (s *FwdItem) BuildUrl(ip net.IP, port uint16, req *http.Request) *url.URL
- func (s *FwdItem) Init()
- func (s *FwdItem) MiddlewareFunc() (fn echo.MiddlewareFunc)
- func (s *FwdItem) Proxy() (p *proxy.TinyProxy)
- func (s *FwdItem) PutVersion(res *http.Response, target *url.URL)
- func (s *FwdItem) SetBalancer(bal middleware.ProxyBalancer)
- func (s *FwdItem) SetMiddlewareFunc(fn echo.MiddlewareFunc)
- func (s *FwdItem) SetProxy(p *proxy.TinyProxy)
- func (s *FwdItem) Shutdown()
- func (s *FwdItem) StatsIncreaseHit(target *middleware.ProxyTarget, ctx echo.Context, res *http.Request)
- func (s *FwdItem) StatsIncreaseReq(target *middleware.ProxyTarget, ctx echo.Context, req *http.Request, ...)
- func (s *FwdItem) StatsIncreaseResp(target *middleware.ProxyTarget, ctx echo.Context, res *http.Response, ...)
- type GwBackend
- type GwBalancer
- type LoadBal
- type LoadBalanceSmart
- type Mock
- type Registrar
- func (s *Registrar) Close()
- func (s *Registrar) GetStore() store.KVStore
- func (s *Registrar) IsOpen() bool
- func (s *Registrar) Open()
- func (s *Registrar) SvrRecordDeregister(serviceName string, all bool) (err error)
- func (s *Registrar) SvrRecordRegister(serviceName, version string) (err error)
- func (s *Registrar) SvrRecordResolver(serviceName, ver, what string) (net.IP, uint16, string)
- func (s *Registrar) SvrRecordResolverAll(serviceName string, what string) []*store.ServiceRecord
- type Stub
- type Targets
- type To
- type VersionSetter
Constants ¶
View Source
const ( TYPE_MS = "ms" TYPE_HTTP = "http" TYPE_MOCK = "mock" AUTH_TYPE_NONE = "none" AUTH_TYPE_BASIC = "basic" AUTH_TYPE_HEADER = "header" AUTH_TYPE_JWT = "jwt" AUTH_TYPE_OAUTH1 = "oauth1" AUTH_TYPE_OAUTH2 = "oauth2" DEFAULT_SERVICE_SUFFIX = ".service.consul." DEFAULT_DNS_SERVER = "127.0.0.1:8600" )
Variables ¶
View Source
var ( // DefaultGzipConfig is the default Gzip middleware config. DefaultForwardersConfig = Config{ Forwarders: []*FwdItem{}, Skipper: middleware.DefaultSkipper, } HeaderXServer = false ThisConfig Config )
View Source
var (
DefaultGwBackend = &defaultBackend{}
)
Functions ¶
func ContextReplacer ¶
func ContextReplacer(h echo.HandlerFunc) echo.HandlerFunc
Types ¶
type Auth ¶
type Auth struct { // basic auth, header(jwt), key-based: oauth1, oauth2, ... Type string `json:"type,omitempty" yaml:"type,omitempty"` Username string `json:"userid,omitempty" yaml:"userid,omitempty"` Password string `json:"passwd,omitempty" yaml:"passwd,omitempty"` Header string `json:"header,omitempty" yaml:"header,omitempty"` AppKey string `json:"appkey,omitempty" yaml:"appkey,omitempty"` AppSecret string `json:"secret,omitempty" yaml:"secret,omitempty"` }
Auth 提供目标服务的认证方案,注意通常不需要
type CircuitBreakAt ¶
type CircuitBreakAt struct { Failed int `json:"failed,omitempty" yaml:"failed,omitempty"` Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"` CannotResolve int `json:"cannotresolve,omitempty" yaml:"cannotresolve,omitempty"` HTTP5xx int `json:"5xx,omitempty" yaml:"5xx,omitempty"` HTTP4xx int `json:"4xx,omitempty" yaml:"4xx,omitempty"` }
type Config ¶
type Config struct { Forwarders []*FwdItem `json:"forwarders" yaml:"forwarders,flow"` Registrar Registrar `json:"registrar" yaml:"registrar,flow"` Skipper middleware.Skipper `json:"_,omitempty" yaml:",omitempty"` // Skipper defines a function to skip middleware. UniqueFwdIDMap map[string]int `json:"_,omitempty" yaml:",omitempty"` UniqueLbIDMap map[string]int `json:"_,omitempty" yaml:",omitempty"` UniqueLbIDInt int `json:"_,omitempty" yaml:",omitempty"` Echo *echo.Echo `json:"_,omitempty" yaml:",omitempty"` }
Config a forwarders configurations inside main app config file (meta.yaml)
func GetAppConfig ¶
func GetAppConfig() *Config
type FwdItem ¶
type FwdItem struct { ID string `json:"id" yaml:"id"` Type string `json:"type" yaml:"type"` Match string `json:"match" yaml:"match"` To To `json:"to,omitempty" yaml:"to,omitempty"` Targets []string `json:"targets,flow,omitempty" yaml:"targets,flow,omitempty"` Mocks []*Mock `json:"mocks,omitempty" yaml:"mocks,omitempty"` Lb *LoadBal `json:"lb,omitempty" yaml:"lb,omitempty"` DowngradeToHttp1 bool `json:"downgrade-to-http1,omitempty" yaml:"downgrade-to-http1,omitempty"` ReverseRewrite bool `json:"reverse-rewrite,omitempty" yaml:"reverse-rewrite,omitempty"` Insecure bool `json:"insecure,omitempty" yaml:"insecure,omitempty"` NoTrailingSlash bool `json:"no-trailing-slash,omitempty" yaml:"no-trailing-slash,omitempty"` Description string `json:"desc,omitempty" yaml:"desc,omitempty"` WhiteLists []string `json:"white-lists,omitempty" yaml:"white-lists,omitempty"` BlackLists []string `json:"black-lists,omitempty" yaml:"black-lists,omitempty"` Disabled bool `json:"disabled,omitempty" yaml:"disabled,omitempty"` BreakAtFailured int `json:"break-at-failure,omitempty" yaml:"break-at-failure,omitempty"` Auth Auth `json:"auth,omitempty" yaml:"auth,omitempty"` ForceUpdate bool `json:"force-update,omitempty" yaml:"force-update,omitempty"` // contains filtered or unexported fields }
Forwarder to define a forwarder/proxy/reverse-proxy to micro-service/external-service/...
func (*FwdItem) Balancer ¶
func (s *FwdItem) Balancer() (bal middleware.ProxyBalancer)
func (*FwdItem) BalancerIsEmpty ¶
func (*FwdItem) MiddlewareFunc ¶
func (s *FwdItem) MiddlewareFunc() (fn echo.MiddlewareFunc)
func (*FwdItem) PutVersion ¶
PutVersion 专用于放置从后端响应头中提取到的版本号相关信息
func (*FwdItem) SetBalancer ¶
func (s *FwdItem) SetBalancer(bal middleware.ProxyBalancer)
func (*FwdItem) SetMiddlewareFunc ¶
func (s *FwdItem) SetMiddlewareFunc(fn echo.MiddlewareFunc)
func (*FwdItem) StatsIncreaseHit ¶
func (s *FwdItem) StatsIncreaseHit(target *middleware.ProxyTarget, ctx echo.Context, res *http.Request)
func (*FwdItem) StatsIncreaseReq ¶
func (s *FwdItem) StatsIncreaseReq(target *middleware.ProxyTarget, ctx echo.Context, req *http.Request, url *url.URL, realIP string)
func (*FwdItem) StatsIncreaseResp ¶
func (s *FwdItem) StatsIncreaseResp(target *middleware.ProxyTarget, ctx echo.Context, res *http.Response, url *url.URL, realIP string)
type GwBalancer ¶
type GwBalancer interface { GetID() string // GetBackend returns the real backend object from the balancer GetBackend(target *middleware.ProxyTarget) GwBackend }
type LoadBal ¶
type LoadBal struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Algorithm string `json:"alg" yaml:"alg"` CircuitBreakAt *CircuitBreakAt `json:"break" yaml:"break"` Smart *LoadBalanceSmart `json:"smart,omitempty" yaml:"smart,omitempty"` }
type LoadBalanceSmart ¶
type Registrar ¶
type Registrar struct { Enabled bool `json:"enabled" yaml:"enabled"` Source string `json:"source" yaml:"source"` Env string `json:"env" yaml:"env"` TTL int64 `json:"ttl,omitempty" yaml:"ttl,omitempty"` Consul map[string]*store.ConsulConfig `json:"consul,omitempty" yaml:"consul,omitempty"` Etcd map[string]*store.Etcdtool `json:"etcd,omitempty" yaml:"etcd,omitempty"` DNSAtFirst bool `json:"dns-at-first,omitempty" yaml:"dns-at-first,omitempty"` // contains filtered or unexported fields }
func (*Registrar) SvrRecordDeregister ¶
func (*Registrar) SvrRecordRegister ¶
SvrRecordRegister 注册服务到登记库中
func (*Registrar) SvrRecordResolver ¶
SvrRecordResolver 返回单一一条可用服务记录(总是返回首条) return net.IPv4zero, 0 means there are no more targets to be found
func (*Registrar) SvrRecordResolverAll ¶
func (s *Registrar) SvrRecordResolverAll(serviceName string, what string) []*store.ServiceRecord
SvrRecordResolverAll 返回全部可用的服务记录
return all addresses if the service
for ETCD, `what` can be "addr", "grpc" for CONSUL, `what` should be empty string now
type Stub ¶
type Stub struct {
Forwarders []FwdItem `json:"forwarders" yaml:"forwarders,flow"`
}
Stud is just a structure stub used for yaml converter
type Targets ¶
type Targets struct {
Value []string `json:"target,omitempty" yaml:"target,omitempty"`
}
Targets present a set of endpoints about that external/internal RESTful service
Click to show internal directories.
Click to hide internal directories.