Documentation
¶
Index ¶
- Constants
- type AutocertManager
- type CacheControl
- type ErrorReporter
- type FailoverSelector
- type Http
- type LBSelector
- type LBSelectorFunc
- type Matcher
- type MatcherMock
- func (mock *MatcherMock) CheckHealth() map[string]error
- func (mock *MatcherMock) CheckHealthCalls() []struct{}
- func (mock *MatcherMock) Mappers() []discovery.URLMapper
- func (mock *MatcherMock) MappersCalls() []struct{}
- func (mock *MatcherMock) Match(srv string, src string) discovery.Matches
- func (mock *MatcherMock) MatchCalls() []struct{ ... }
- func (mock *MatcherMock) Servers() []string
- func (mock *MatcherMock) ServersCalls() []struct{}
- type MiddlewareProvider
- type OFLookup
- type OnlyFrom
- type RandomSelector
- type Reporter
- type RoundRobinSelector
- type SSLConfig
- type Timeouts
Constants ¶
const ( // SSLNone defines to run http server only SSLNone sslMode = iota // SSLStatic defines to run both https and http server. Redirect http to https SSLStatic // SSLAuto defines to run both https and http server. Redirect http to https. Https server with autocert support SSLAuto )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutocertManager ¶ added in v1.3.0
type AutocertManager interface {
GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
HTTPHandler(http.Handler) http.Handler
CheckDomain(ctx context.Context, name string) error
}
AutocertManager specifies methods for the automatic ACME certificate manager to implement
type CacheControl ¶ added in v0.5.0
type CacheControl struct {
// contains filtered or unexported fields
}
CacheControl sets Cache-Control response header with different ages for different mimes
func MakeCacheControl ¶ added in v0.5.0
func MakeCacheControl(cacheOpts []string) (*CacheControl, error)
MakeCacheControl creates CacheControl from the list of params. the first param represents default age and can be just a duration string (i.e. 60h) or "default:60h" all other params are mime:duration pairs, i.e. "text/html:30s"
func NewCacheControl ¶ added in v0.5.0
func NewCacheControl(defaultAge time.Duration) *CacheControl
NewCacheControl creates NewCacheControl with the default max age
func (*CacheControl) AddMime ¶ added in v0.5.0
func (c *CacheControl) AddMime(m string, d time.Duration)
AddMime sets max age for a given mime
func (*CacheControl) Middleware ¶ added in v0.5.0
func (c *CacheControl) Middleware(next http.Handler) http.Handler
Middleware checks if mime custom age set and returns it if matched to content type from resource (file) extension. fallback to default if nothing matched
type ErrorReporter ¶ added in v0.5.0
ErrorReporter formats error with a given template Supports go-style template with {{.ErrMessage}} and {{.ErrCode}}
func (*ErrorReporter) Report ¶ added in v0.5.0
func (em *ErrorReporter) Report(w http.ResponseWriter, code int)
Report formats and sends error to ResponseWriter
type FailoverSelector ¶ added in v1.1.0
type FailoverSelector struct{}
FailoverSelector is a selector with failover, thread-safe
func (*FailoverSelector) Select ¶ added in v1.1.0
func (r *FailoverSelector) Select(_ int) int
Select returns next backend index
type Http ¶
type Http struct {
Matcher
Address string
AssetsLocation string
AssetsWebRoot string
Assets404 string
AssetsSPA bool
MaxBodySize int64
GzEnabled bool
ProxyHeaders []string
DropHeader []string
SSLConfig SSLConfig
Insecure bool
Version string
AccessLog io.Writer
StdOutEnabled bool
Signature bool
Timeouts Timeouts
CacheControl MiddlewareProvider
Metrics MiddlewareProvider
PluginConductor MiddlewareProvider
Reporter Reporter
LBSelector LBSelector
OnlyFrom *OnlyFrom
BasicAuthEnabled bool
BasicAuthAllowed []string
ThrottleSystem int
ThrottleUser int
KeepHost bool
UpstreamMaxIdleConns int
UpstreamMaxConnsPerHost int
// contains filtered or unexported fields
}
Http is a proxy server for both http and https
type LBSelector ¶ added in v1.1.0
LBSelector defines load balancer strategy
type LBSelectorFunc ¶ added in v1.1.0
LBSelectorFunc is a functional adapted for LBSelector to select backend from the list
func (LBSelectorFunc) Select ¶ added in v1.1.0
func (f LBSelectorFunc) Select(n int) int
Select returns backend index
type Matcher ¶
type Matcher interface {
Match(srv, src string) (res discovery.Matches)
Servers() (servers []string)
Mappers() (mappers []discovery.URLMapper)
CheckHealth() (pingResult map[string]error)
}
Matcher source info (server and route) to the destination url If no match found return ok=false
type MatcherMock ¶ added in v0.8.0
type MatcherMock struct {
// CheckHealthFunc mocks the CheckHealth method.
CheckHealthFunc func() map[string]error
// MappersFunc mocks the Mappers method.
MappersFunc func() []discovery.URLMapper
// MatchFunc mocks the Match method.
MatchFunc func(srv string, src string) discovery.Matches
// ServersFunc mocks the Servers method.
ServersFunc func() []string
// contains filtered or unexported fields
}
MatcherMock is a mock implementation of Matcher.
func TestSomethingThatUsesMatcher(t *testing.T) {
// make and configure a mocked Matcher
mockedMatcher := &MatcherMock{
CheckHealthFunc: func() map[string]error {
panic("mock out the CheckHealth method")
},
MappersFunc: func() []discovery.URLMapper {
panic("mock out the Mappers method")
},
MatchFunc: func(srv string, src string) discovery.Matches {
panic("mock out the Match method")
},
ServersFunc: func() []string {
panic("mock out the Servers method")
},
}
// use mockedMatcher in code that requires Matcher
// and then make assertions.
}
func (*MatcherMock) CheckHealth ¶ added in v0.8.0
func (mock *MatcherMock) CheckHealth() map[string]error
CheckHealth calls CheckHealthFunc.
func (*MatcherMock) CheckHealthCalls ¶ added in v0.8.0
func (mock *MatcherMock) CheckHealthCalls() []struct { }
CheckHealthCalls gets all the calls that were made to CheckHealth. Check the length with:
len(mockedMatcher.CheckHealthCalls())
func (*MatcherMock) Mappers ¶ added in v0.8.0
func (mock *MatcherMock) Mappers() []discovery.URLMapper
Mappers calls MappersFunc.
func (*MatcherMock) MappersCalls ¶ added in v0.8.0
func (mock *MatcherMock) MappersCalls() []struct { }
MappersCalls gets all the calls that were made to Mappers. Check the length with:
len(mockedMatcher.MappersCalls())
func (*MatcherMock) Match ¶ added in v0.8.0
func (mock *MatcherMock) Match(srv string, src string) discovery.Matches
Match calls MatchFunc.
func (*MatcherMock) MatchCalls ¶ added in v0.8.0
func (mock *MatcherMock) MatchCalls() []struct { Srv string Src string }
MatchCalls gets all the calls that were made to Match. Check the length with:
len(mockedMatcher.MatchCalls())
func (*MatcherMock) Servers ¶ added in v0.8.0
func (mock *MatcherMock) Servers() []string
Servers calls ServersFunc.
func (*MatcherMock) ServersCalls ¶ added in v0.8.0
func (mock *MatcherMock) ServersCalls() []struct { }
ServersCalls gets all the calls that were made to Servers. Check the length with:
len(mockedMatcher.ServersCalls())
type MiddlewareProvider ¶ added in v0.5.0
MiddlewareProvider interface defines http middleware handler
type OnlyFrom ¶ added in v1.1.0
type OnlyFrom struct {
// contains filtered or unexported fields
}
OnlyFrom implements middleware to allow access for a limited list of source IPs.
func NewOnlyFrom ¶ added in v1.1.0
NewOnlyFrom creates OnlyFrom middleware with given lookup methods.
type RandomSelector ¶ added in v1.1.0
type RandomSelector struct{}
RandomSelector is a random selector, thread-safe
func (*RandomSelector) Select ¶ added in v1.1.0
func (r *RandomSelector) Select(n int) int
Select returns random backend index
type Reporter ¶ added in v0.5.0
type Reporter interface {
Report(w http.ResponseWriter, code int)
}
Reporter defines error reporting service
type RoundRobinSelector ¶ added in v1.1.0
type RoundRobinSelector struct {
// contains filtered or unexported fields
}
RoundRobinSelector is a simple round-robin selector, thread-safe
func (*RoundRobinSelector) Select ¶ added in v1.1.0
func (r *RoundRobinSelector) Select(n int) int
Select returns next backend index
type SSLConfig ¶
type SSLConfig struct {
SSLMode sslMode
Cert string
Key string
RedirHTTPPort int
ACMEDirectory string // URL of the ACME directory to use
ACMELocation string // directory where the obtained certificates are stored
ACMEEmail string // email address to use for the ACME account
FQDNs []string // list of fully qualified domain names to manage certificates for
DNSProvider certmagic.DNSProvider // provider to use for DNS-01 challenges
TTL time.Duration // TTL to use when setting DNS records for DNS-01 challenges
}
SSLConfig holds all ssl params for rest server
type Timeouts ¶ added in v0.2.0
type Timeouts struct {
// server timeouts
ReadHeader time.Duration
Write time.Duration
Idle time.Duration
// transport timeouts
Dial time.Duration
KeepAlive time.Duration
IdleConn time.Duration
TLSHandshake time.Duration
ExpectContinue time.Duration
ResponseHeader time.Duration
}
Timeouts consolidate timeouts for both server and transport