Documentation ¶
Overview ¶
Package proxy provides proxy and proxy middleware interfaces and implementations
Index ¶
- Constants
- Variables
- func AllowlistPrune(wlDict map[string]interface{}, inDict map[string]interface{}) bool
- func CloneRequestHeaders(headers map[string][]string) map[string][]string
- func CloneRequestParams(params map[string]string) map[string]string
- func NewReadCloserWrapper(ctx context.Context, in io.ReadCloser) io.Reader
- func RegisterResponseCombiner(name string, f ResponseCombiner)
- type BackendFactory
- type EntityFormatter
- type EntityFormatterFunc
- type Factory
- func DefaultFactory(logger log.Logger) Factory
- func DefaultFactoryWithSubscriber(logger log.Logger, sF discovery.SubscriberFactory) Factory
- func NewDefaultFactory(backendFactory BackendFactory, logger log.Logger) Factory
- func NewDefaultFactoryWithSubscriber(backendFactory BackendFactory, logger log.Logger, ...) Factory
- func NewShadowFactory(f Factory) Factory
- type FactoryFunc
- type HTTPResponseParser
- type HTTPResponseParserConfig
- type HTTPResponseParserFactory
- type Metadata
- type Middleware
- func NewBackendPluginMiddleware(remote *config.Backend) Middleware
- func NewConcurrentMiddleware(remote *config.Backend) Middleware
- func NewFlatmapMiddleware(cfg *config.EndpointConfig) Middleware
- func NewGraphQLMiddleware(remote *config.Backend) Middleware
- func NewLoadBalancedMiddleware(remote *config.Backend) Middleware
- func NewLoadBalancedMiddlewareWithSubscriber(subscriber discovery.Subscriber) Middleware
- func NewLoggingMiddleware(logger log.Logger, name string) Middleware
- func NewMergeDataMiddleware(endpointConfig *config.EndpointConfig) Middleware
- func NewPluginMiddleware(endpoint *config.EndpointConfig) Middleware
- func NewRandomLoadBalancedMiddleware(remote *config.Backend) Middleware
- func NewRandomLoadBalancedMiddlewareWithSubscriber(subscriber discovery.Subscriber) Middleware
- func NewRequestBuilderMiddleware(remote *config.Backend) Middleware
- func NewRoundRobinLoadBalancedMiddleware(remote *config.Backend) Middleware
- func NewRoundRobinLoadBalancedMiddlewareWithSubscriber(subscriber discovery.Subscriber) Middleware
- func NewStaticMiddleware(endpointConfig *config.EndpointConfig) Middleware
- type Proxy
- func EmptyMiddleware(next ...Proxy) Proxy
- func NewHTTPProxy(remote *config.Backend, cf client.HTTPClientFactory, decode encoding.Decoder) Proxy
- func NewHTTPProxyDetailed(remote *config.Backend, re client.HTTPRequestExecutor, ...) Proxy
- func NewHTTPProxyWithHTTPExecutor(remote *config.Backend, re client.HTTPRequestExecutor, dec encoding.Decoder) Proxy
- func NewShadowProxy(p1, p2 Proxy) Proxy
- func ShadowMiddleware(next ...Proxy) Proxy
- type Register
- type Request
- type RequestWrapper
- type Response
- type ResponseCombiner
- type ResponseMetadataWrapper
- type ResponseWrapper
Constants ¶
View Source
const Namespace = "github.com/starvn/turbo/proxy"
Variables ¶
View Source
var ( ErrNoBackends = errors.New("all endpoints must have at least one backend") ErrTooManyBackends = errors.New("too many backends for this proxy") ErrTooManyProxies = errors.New("too many proxies for this proxy middleware") ErrNotEnoughProxies = errors.New("not enough proxies for this endpoint") )
View Source
var DefaultHTTPResponseParserConfig = HTTPResponseParserConfig{ func(_ io.Reader, _ *map[string]interface{}) error { return nil }, EntityFormatterFunc(func(r Response) Response { return r }), }
Functions ¶
func AllowlistPrune ¶
func CloneRequestHeaders ¶
func NewReadCloserWrapper ¶
func RegisterResponseCombiner ¶
func RegisterResponseCombiner(name string, f ResponseCombiner)
Types ¶
type BackendFactory ¶
func CustomHTTPProxyFactory ¶
func CustomHTTPProxyFactory(cf client.HTTPClientFactory) BackendFactory
func HTTPProxyFactory ¶
func HTTPProxyFactory(client *http.Client) BackendFactory
type EntityFormatter ¶
func NewEntityFormatter ¶
func NewEntityFormatter(remote *config.Backend) EntityFormatter
type EntityFormatterFunc ¶
func (EntityFormatterFunc) Format ¶
func (e EntityFormatterFunc) Format(entity Response) Response
type Factory ¶
type Factory interface {
New(cfg *config.EndpointConfig) (Proxy, error)
}
func DefaultFactory ¶
func DefaultFactoryWithSubscriber ¶
func DefaultFactoryWithSubscriber(logger log.Logger, sF discovery.SubscriberFactory) Factory
func NewDefaultFactory ¶
func NewDefaultFactory(backendFactory BackendFactory, logger log.Logger) Factory
func NewDefaultFactoryWithSubscriber ¶
func NewDefaultFactoryWithSubscriber(backendFactory BackendFactory, logger log.Logger, sF discovery.SubscriberFactory) Factory
func NewShadowFactory ¶
type FactoryFunc ¶
type FactoryFunc func(*config.EndpointConfig) (Proxy, error)
func (FactoryFunc) New ¶
func (f FactoryFunc) New(cfg *config.EndpointConfig) (Proxy, error)
type HTTPResponseParser ¶
func DefaultHTTPResponseParserFactory ¶
func DefaultHTTPResponseParserFactory(cfg HTTPResponseParserConfig) HTTPResponseParser
type HTTPResponseParserConfig ¶
type HTTPResponseParserConfig struct { Decoder encoding.Decoder EntityFormatter EntityFormatter }
type HTTPResponseParserFactory ¶
type HTTPResponseParserFactory func(HTTPResponseParserConfig) HTTPResponseParser
type Middleware ¶
func NewBackendPluginMiddleware ¶
func NewBackendPluginMiddleware(remote *config.Backend) Middleware
func NewConcurrentMiddleware ¶
func NewConcurrentMiddleware(remote *config.Backend) Middleware
func NewFlatmapMiddleware ¶
func NewFlatmapMiddleware(cfg *config.EndpointConfig) Middleware
func NewGraphQLMiddleware ¶
func NewGraphQLMiddleware(remote *config.Backend) Middleware
func NewLoadBalancedMiddleware ¶
func NewLoadBalancedMiddleware(remote *config.Backend) Middleware
func NewLoadBalancedMiddlewareWithSubscriber ¶
func NewLoadBalancedMiddlewareWithSubscriber(subscriber discovery.Subscriber) Middleware
func NewLoggingMiddleware ¶
func NewLoggingMiddleware(logger log.Logger, name string) Middleware
func NewMergeDataMiddleware ¶
func NewMergeDataMiddleware(endpointConfig *config.EndpointConfig) Middleware
func NewPluginMiddleware ¶
func NewPluginMiddleware(endpoint *config.EndpointConfig) Middleware
func NewRandomLoadBalancedMiddleware ¶
func NewRandomLoadBalancedMiddleware(remote *config.Backend) Middleware
func NewRandomLoadBalancedMiddlewareWithSubscriber ¶
func NewRandomLoadBalancedMiddlewareWithSubscriber(subscriber discovery.Subscriber) Middleware
func NewRequestBuilderMiddleware ¶
func NewRequestBuilderMiddleware(remote *config.Backend) Middleware
func NewRoundRobinLoadBalancedMiddleware ¶
func NewRoundRobinLoadBalancedMiddleware(remote *config.Backend) Middleware
func NewRoundRobinLoadBalancedMiddlewareWithSubscriber ¶
func NewRoundRobinLoadBalancedMiddlewareWithSubscriber(subscriber discovery.Subscriber) Middleware
func NewStaticMiddleware ¶
func NewStaticMiddleware(endpointConfig *config.EndpointConfig) Middleware
type Proxy ¶
func EmptyMiddleware ¶
func NewHTTPProxy ¶
func NewHTTPProxyDetailed ¶
func NewHTTPProxyDetailed(remote *config.Backend, re client.HTTPRequestExecutor, ch client.HTTPStatusHandler, rp HTTPResponseParser) Proxy
func NewShadowProxy ¶
func ShadowMiddleware ¶
type Register ¶
type Register struct {
// contains filtered or unexported fields
}
func NewRegister ¶
func NewRegister() *Register
func (Register) GetResponseCombiner ¶
func (r Register) GetResponseCombiner(name string) (ResponseCombiner, bool)
func (Register) SetResponseCombiner ¶
func (r Register) SetResponseCombiner(name string, rc ResponseCombiner)
type Request ¶
type Request struct { Method string URL *url.URL Query url.Values Path string Body io.ReadCloser Params map[string]string Headers map[string][]string }
func CloneRequest ¶
func (*Request) GeneratePath ¶
type RequestWrapper ¶
type Response ¶
func NoOpHTTPResponseParser ¶
type ResponseCombiner ¶
type ResponseMetadataWrapper ¶
type ResponseWrapper ¶
type ResponseWrapper interface { Data() map[string]interface{} Io() io.Reader IsComplete() bool Metadata() ResponseMetadataWrapper }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.