proxy

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	RequestConfigProvider RequestConfigProvider
	InvokerPool           *middleware.InvokerPool
	BufferPool            sync.Pool
	ClientPool            sync.Pool
}

type Request added in v1.5.0

type Request struct {
	Config         *RequestConfig
	RequestURL     url.URL
	Body           io.Reader
	Context        context.Context
	GraphQLRequest middleware.GraphQLRequest
}

type RequestConfig added in v1.4.0

type RequestConfig struct {
	// Schema is a pointer to the publicly exposed schema by the proxy
	Schema *[]byte
	// BackendURL is the URL of the backend origin graphql server
	BackendURL url.URL
	// AddHeadersToContext are the headers that should be extracted from a request to the proxy and added to the context
	// from the context the headers are available to graphql middleWares, e.g. to set variables
	AddHeadersToContext [][]byte
	// BackendHeaders are headers that should be statically set to backend requests
	// This could be used to add authentication to securely communicate with the origin server
	BackendHeaders map[string][]string
}

RequestConfig configures how the proxy should handle a request

type RequestConfigProvider added in v1.4.0

type RequestConfigProvider interface {
	GetRequestConfig(ctx context.Context) RequestConfig
}

RequestConfigProvider is the interface to retrieve the configuration to handle a request based on the provided information in the context the implementation might decide how to set the request config This could be used to dynamically decide which backend should be used to satisfy a request On the other hand the context could be ignored and you simply return a static configuration for all requests You can basically use any http middleware in front of the request config provider and setup the request context After that it's up to the RequestConfigProvider implementation how to set the configuration This should give the user enough flexibility

type RequestInterface added in v1.5.0

type RequestInterface interface {
	AcceptRequest(buff *bytes.Buffer) error
	DispatchRequest(buff *bytes.Buffer) (io.ReadCloser, error)
	AcceptResponse()
	DispatchResponse()
}

type StaticRequestConfigProvider added in v1.4.0

type StaticRequestConfigProvider struct {
	// contains filtered or unexported fields
}

func NewStaticRequestConfigProvider added in v1.5.0

func NewStaticRequestConfigProvider(config RequestConfig) *StaticRequestConfigProvider

func (*StaticRequestConfigProvider) GetRequestConfig added in v1.4.0

func (s *StaticRequestConfigProvider) GetRequestConfig(ctx context.Context) RequestConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL