Documentation
¶
Index ¶
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 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 Http ¶
type Http struct {
Matcher
Address string
AssetsLocation string
AssetsWebRoot string
MaxBodySize int64
GzEnabled bool
ProxyHeaders []string
SSLConfig SSLConfig
Version string
AccessLog io.Writer
StdOutEnabled bool
Signature bool
Timeouts Timeouts
CacheControl MiddlewareProvider
Metrics MiddlewareProvider
Reporter Reporter
LBSelector func(len int) int
}
Http is a proxy server for both http and https
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 MiddlewareProvider ¶ added in v0.5.0
MiddlewareProvider interface defines http middleware handler
type Reporter ¶ added in v0.5.0
type Reporter interface {
Report(w http.ResponseWriter, code int)
}
Reporter defines error reporting service
type SSLConfig ¶
type SSLConfig struct {
SSLMode sslMode
Cert string
Key string
ACMELocation string
ACMEEmail string
FQDNs []string
RedirHTTPPort int
}
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