ErrorWriter is a function that can be used to return a standard formatted error to the client.
A Gateway can be used as an api gateway.
New returns a new Gateway.
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 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 func(*gwconfig)
A Option represents possible options for the Gateway.
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 "*"
OptionBlockOpenTracingHeaders configures if the gateway should strip any open tracing related header coming from the clients.
OptionEnableMaintenance enables the maintenance mode.
OptionEnableProxyProtocol enables and configure the support for ProxyProtocol.
OptionEnableTrace enables deep oxy logging.
OptionExposePrivateAPIs configures if the gateway should expose the private apis.
OptionHTTPTimeouts configures the HTTP timeouts.
OptionMetricsManager registers a given PrefixInterceptorFunc for the given path prefix.
OptionRateLimiting enables and configures the HTTP rate limiter.
OptionRegisterExactInterceptor registers a given InterceptorFunc for the given path.
OptionRegisterPrefixInterceptor registers a given InterceptorFunc for the given path prefix.
OptionRegisterSuffixInterceptor registers a given InterceptorFunc for the given path suffix.
OptionServerTLSConfig sets the tls.Config to use for the front end server.
OptionSetCustomRequestRewriter sets a custom RequestRewriter.
OptionSetCustomResponseRewriter sets a custom ResponseRewriter.
OptionTCPRateLimiting enables and configures the TCP rate limiter.
OptionUpstreamConfig configures the connections to the upstream backends.
OptionUpstreamTLSConfig sets the tls.Config to use for the upstream servers.
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.
A ResponseRewriter can be used to rewrite the response before it is sent back to the client
An Upstreamer is the interface that can conpute upstreams.