Documentation
¶
Index ¶
- Constants
- Variables
- func NewBackend(ctx *hclsyntax.Body, tc *Config, opts *BackendOptions, log *logrus.Entry) http.RoundTripper
- func NewProbe(log *logrus.Entry, tc *Config, opts *config.HealthCheck, ...)
- func NewTransport(conf *Config, log *logrus.Entry) *http.Transport
- func ReadCertificates(conf *config.BackendTLS) (tls.Certificate, tls.Certificate, error)
- func RemoveConnectionHeaders(h http.Header)
- func RemoveHopHeaders(header http.Header)
- type Backend
- type BackendOptions
- type Config
- type HealthInfo
- type OAuth2ReqAuth
- type OriginConn
- type Probe
- type ProbeStateChange
- type RequestAuthorizer
- type TokenRequest
Constants ¶
const ( StateInvalid state = iota StateOk StateFailing StateDown )
Variables ¶
var HopHeaders = []string{
"Connection",
"Proxy-Connection",
"Keep-Alive",
"Proxy-Authenticate",
"Proxy-Authorization",
"Te",
"Trailer",
"Transfer-Encoding",
"Upgrade",
}
HopHeaders Hop-by-hop headers. These are removed when sent to the backend. As of RFC 7230, hop-by-hop headers are required to appear in the Connection header field. These are the headers defined by the obsoleted RFC 2616 (section 13.5.1) and are used for backward compatibility.
Functions ¶
func NewBackend ¶
func NewBackend(ctx *hclsyntax.Body, tc *Config, opts *BackendOptions, log *logrus.Entry) http.RoundTripper
NewBackend creates a new <*Backend> object by the given <*Config>.
func NewProbe ¶
func NewProbe(log *logrus.Entry, tc *Config, opts *config.HealthCheck, listener ProbeStateChange)
func NewTransport ¶
NewTransport creates a new <*http.Transport> object by the given <*Config>.
func ReadCertificates ¶
func ReadCertificates(conf *config.BackendTLS) (tls.Certificate, tls.Certificate, error)
ReadCertificates parses an optional CA certificate or a client certificate / key pair. It is valid to have just the client pair without the CA certificate since the system Root CAs or the related Couper cli option MAY configure the related transport too.
func RemoveConnectionHeaders ¶
RemoveConnectionHeaders removes hop-by-hop headers listed in the "Connection" header of h. See RFC 7230, section 6.1
func RemoveHopHeaders ¶
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func (*Backend) OnProbeChange ¶
func (b *Backend) OnProbeChange(info *HealthInfo)
type BackendOptions ¶
type BackendOptions struct {
RequestAuthz []RequestAuthorizer
HealthCheck *config.HealthCheck
OpenAPI *validation.OpenAPIOptions
}
BackendOptions represents the transport <BackendOptions> object.
type Config ¶
type Config struct {
BackendName string
DisableCertValidation bool
DisableConnectionReuse bool
HTTP2 bool
MaxConnections int
NoProxyFromEnv bool
Proxy string
Throttles throttle.Throttles
ConnectTimeout time.Duration
TTFBTimeout time.Duration
Timeout time.Duration
// TLS settings
// Certificate is passed to all backends from the related cli option.
Certificate []byte
// CACertificate contains a per backend configured one.
CACertificate tls.Certificate
// ClientCertificate holds the one the backend will send during tls handshake if required.
ClientCertificate tls.Certificate
// Dynamic values
Context context.Context
Hostname string
Origin string
Scheme string
}
Config represents the transport <Config> object.
func (*Config) WithTarget ¶
type OAuth2ReqAuth ¶
type OAuth2ReqAuth struct {
// contains filtered or unexported fields
}
OAuth2ReqAuth represents the transport <OAuth2ReqAuth> object.
func (*OAuth2ReqAuth) RetryWithToken ¶
type OriginConn ¶
OriginConn wraps the original net.Conn created by net.DialContext or transport.DialTLS for debug purposes.
func NewOriginConn ¶
func NewOriginConn(ctx context.Context, conn net.Conn, conf *Config, entry *logrus.Entry) *OriginConn
NewOriginConn creates a new wrapper with logging context.
func (*OriginConn) Close ¶
func (o *OriginConn) Close() error
type ProbeStateChange ¶
type ProbeStateChange interface {
OnProbeChange(info *HealthInfo)
}
type RequestAuthorizer ¶
type RequestAuthorizer interface {
GetToken(req *http.Request) error
RetryWithToken(req *http.Request, res *http.Response) (bool, error)
// contains filtered or unexported methods
}
func NewOAuth2ReqAuth ¶
func NewOAuth2ReqAuth(evalCtx *hcl.EvalContext, conf *config.OAuth2ReqAuth, memStore *cache.MemoryStore, asBackend http.RoundTripper) (RequestAuthorizer, error)
NewOAuth2ReqAuth implements the http.RoundTripper interface to wrap an existing Backend / http.RoundTripper to retrieve a valid token before passing the initial out request.
func NewTokenRequest ¶
func NewTokenRequest(conf *config.TokenRequest, memStore *cache.MemoryStore, reqProducer producer.Roundtrip) (RequestAuthorizer, error)
type TokenRequest ¶
type TokenRequest struct {
// contains filtered or unexported fields
}