Documentation ¶
Index ¶
- type ErrorWriter
- type Gateway
- type InterceptorAction
- type InterceptorFunc
- type Option
- func OptionAllowedCORSOrigin(origin string) Option
- func OptionBlockOpenTracingHeaders(block bool) Option
- func OptionEnableMaintenance(enabled bool) Option
- func OptionEnableProxyProtocol(enabled bool, subnet string) Option
- func OptionEnableTrace(enabled bool) Option
- func OptionExposePrivateAPIs(enabled bool) Option
- func OptionHTTPTimeouts(read, write, idle time.Duration, disableKeepAlive bool) Option
- func OptionMetricsManager(metricsManager bahamut.MetricsManager) Option
- func OptionRateLimiting(enabled bool, cps int, burst int) Option
- func OptionRegisterExactInterceptor(path string, f InterceptorFunc) Option
- func OptionRegisterPrefixInterceptor(prefix string, f InterceptorFunc) Option
- func OptionRegisterSuffixInterceptor(prefix string, f InterceptorFunc) Option
- func OptionServerTLSConfig(tlsConfig *tls.Config) Option
- func OptionSetCustomRequestRewriter(r RequestRewriter) Option
- func OptionSetCustomResponseRewriter(r ResponseRewriter) Option
- func OptionTCPRateLimiting(enabled bool, cps float64, burst int, maxConnections int) Option
- func OptionUpstreamConfig(upstreamMaxConnsPerHost int, upstreamMaxIdleConns int, ...) Option
- func OptionUpstreamTLSConfig(tlsConfig *tls.Config) Option
- type RequestRewriter
- type ResponseRewriter
- type Upstreamer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorWriter ¶
ErrorWriter is a function that can be used to return a standard formatted error to the client.
type InterceptorAction ¶
type InterceptorAction int
A InterceptorAction represents the decision on how to continue handling the request
const ( // InterceptorActionForward means the Gateway will continue forwarding the request. // In that case the Interceptor must only modify the request, and MUST NOT use // the HTTP response writer. InterceptorActionForward InterceptorAction = iota + 1 // InterceptorActionForwardWS means the Gateway will continue forwarding the request as a websocket. // In that case the Interceptor must only modify the request, and MUST NOT use // the HTTP response writer. InterceptorActionForwardWS // InterceptorActionForwardDirect means the Gateway will continue forwarding the request directly. // In that case the Interceptor must only modify the request, and MUST NOT use // the HTTP response writer. InterceptorActionForwardDirect // InterceptorActionStop means the interceptor handled the request // and the gateway will not do anything more. InterceptorActionStop )
type InterceptorFunc ¶
type InterceptorFunc func(w http.ResponseWriter, req *http.Request, ew ErrorWriter) (action InterceptorAction, upstream string, err error)
An InterceptorFunc is a function that can be used to intercept and request based on its prefix and apply custom operation and returns an InterceptorAction to tell the gateway it should proceed from there. If it returns an error, the error is returned to the client as an internal server error.
NOTE: It is not possible to rewrite the request. To do so, you can use a RequestRewriter.
type Option ¶
type Option func(*gwconfig)
A Option represents possible options for the Gateway.
func OptionAllowedCORSOrigin ¶
OptionAllowedCORSOrigin sets allowed CORS origin. If set to empty, or "*", the gateway will mirror whatever is set in the upcoming request Origin header. This is not secure to be used in production when a browser is calling the gateway.
By default, it is set to "*"
func OptionBlockOpenTracingHeaders ¶
OptionBlockOpenTracingHeaders configures if the gateway should strip any open tracing related header coming from the clients.
func OptionEnableMaintenance ¶
OptionEnableMaintenance enables the maintenance mode.
func OptionEnableProxyProtocol ¶
OptionEnableProxyProtocol enables and configure the support for ProxyProtocol.
func OptionEnableTrace ¶
OptionEnableTrace enables deep oxy logging.
func OptionExposePrivateAPIs ¶
OptionExposePrivateAPIs configures if the gateway should expose the private apis.
func OptionHTTPTimeouts ¶
OptionHTTPTimeouts configures the HTTP timeouts.
func OptionMetricsManager ¶
func OptionMetricsManager(metricsManager bahamut.MetricsManager) Option
OptionMetricsManager registers a given PrefixInterceptorFunc for the given path prefix.
func OptionRateLimiting ¶ added in v1.120.0
OptionRateLimiting enables and configures the HTTP rate limiter.
func OptionRegisterExactInterceptor ¶
func OptionRegisterExactInterceptor(path string, f InterceptorFunc) Option
OptionRegisterExactInterceptor registers a given InterceptorFunc for the given path.
func OptionRegisterPrefixInterceptor ¶
func OptionRegisterPrefixInterceptor(prefix string, f InterceptorFunc) Option
OptionRegisterPrefixInterceptor registers a given InterceptorFunc for the given path prefix.
func OptionRegisterSuffixInterceptor ¶
func OptionRegisterSuffixInterceptor(prefix string, f InterceptorFunc) Option
OptionRegisterSuffixInterceptor registers a given InterceptorFunc for the given path suffix.
func OptionServerTLSConfig ¶
OptionServerTLSConfig sets the tls.Config to use for the front end server.
func OptionSetCustomRequestRewriter ¶
func OptionSetCustomRequestRewriter(r RequestRewriter) Option
OptionSetCustomRequestRewriter sets a custom RequestRewriter.
func OptionSetCustomResponseRewriter ¶
func OptionSetCustomResponseRewriter(r ResponseRewriter) Option
OptionSetCustomResponseRewriter sets a custom ResponseRewriter.
func OptionTCPRateLimiting ¶ added in v1.120.0
OptionTCPRateLimiting enables and configures the TCP rate limiter.
func OptionUpstreamConfig ¶
func OptionUpstreamConfig( upstreamMaxConnsPerHost int, upstreamMaxIdleConns int, upstreamMaxIdleConnsPerHost int, upstreamTLSHandshakeTimeout time.Duration, upstreamIdleConnTimeout time.Duration, upstreamCircuitBreakerCond string, useHTTP2 bool, ) Option
OptionUpstreamConfig configures the connections to the upstream backends.
func OptionUpstreamTLSConfig ¶
OptionUpstreamTLSConfig sets the tls.Config to use for the upstream servers.
type RequestRewriter ¶
A RequestRewriter can be used to rewrite the request before it is sent to the upstream. The private parameter tells if the gateway is configured or not to serve the private APIs.
type ResponseRewriter ¶
A ResponseRewriter can be used to rewrite the response before it is sent back to the client