proxy

package
Version: v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsWebSocketRequest

func IsWebSocketRequest(r *http.Request) bool

IsWebSocketRequest returns a boolean indicating whether the request has the headers of a WebSocket handshake request.

Types

type HTTPReverseProxy

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

HTTPReverseProxy it work with a regular HTTP request

func NewHTTPReverseProxy

func NewHTTPReverseProxy(opts *Options) *HTTPReverseProxy

NewHTTPReverseProxy create new http-proxy-handler

func (*HTTPReverseProxy) Register added in v0.3.1

func (handler *HTTPReverseProxy) Register(srv Service) *HTTPReverseProxy

Register new service

func (*HTTPReverseProxy) ServeHTTP

func (handler *HTTPReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Options added in v0.3.1

type Options struct {
	Postgraphile PostgraphileOptions
	RPC          RPCOptions
}

type PostgraphileOptions added in v0.3.1

type PostgraphileOptions struct {
	Default    *url.URL
	TracingAPI *url.URL
}

type Proxy

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

Proxy accept http and ws requests

func New

func New(opts *Options) *Proxy

New create new router

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RPCOptions added in v0.3.1

type RPCOptions struct {
	DefaultClients []*rpc.Client
	TracingClients []*rpc.Client
}

type Service added in v0.3.1

type Service interface {
	Name() string
	Validate(args []*ast.Argument) error
	IsEmpty(data []byte) (bool, error)
	Do(args []*ast.Argument) error
}

type WebsocketReverseProxy

type WebsocketReverseProxy struct {
	// Director must be a function which modifies
	// the request into a new request to be sent
	// using Transport. Its response is then copied
	// back to the original client unmodified.
	Director func(*http.Request)

	// Dial specifies the dial function for dialing the proxied
	// server over tcp.
	// If Dial is nil, net.Dial is used.
	Dial func(network, addr string) (net.Conn, error)

	// TLSClientConfig specifies the TLS configuration to use for 'wss'.
	// If nil, the default configuration is used.
	TLSClientConfig *tls.Config

	// ErrorLog specifies an optional logger for errors
	// that occur when attempting to proxy the request.
	// If nil, logging goes to os.Stderr via the log package's
	// standard logger.
	ErrorLog *log.Logger
}

WebsocketReverseProxy it will not work with a regular HTTP request, so it is the caller's responsiblity to ensure the incoming request is a WebSocket request.

func NewWebsocketReverseProxy

func NewWebsocketReverseProxy(target *url.URL) *WebsocketReverseProxy

NewWebsocketReverseProxy returns a new websocket ReverseProxy. The path rewrites follow the same rules as the httputil.ReverseProxy. If the target url has the path '/foo' and the incoming request '/bar', the request path will be updated to '/foo/bar' before forwarding. Scheme should specify if 'ws' or 'wss' should be used.

func (*WebsocketReverseProxy) ServeHTTP

Function to implement the http.Handler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL