middlewares

package
v0.0.0-...-400655f Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2015 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultUpgrader specifies the parameters for upgrading an HTTP
	// connection to a WebSocket connection.
	DefaultUpgrader = &websocket.Upgrader{
		ReadBufferSize:  1024,
		WriteBufferSize: 1024,
	}

	// DefaultDialer is a dialer with all fields set to the default zero values.
	DefaultDialer = websocket.DefaultDialer
)

Original developpement made by https://github.com/koding/websocketproxy

Functions

func ProxyHandler

func ProxyHandler(target *url.URL) http.Handler

ProxyHandler returns a new http.Handler interface that reverse proxies the request to the given target.

Types

type CircuitBreaker

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

CircuitBreaker holds the oxy circuit breaker.

func NewCircuitBreaker

func NewCircuitBreaker(next http.Handler, expression string, options ...cbreaker.CircuitBreakerOption) *CircuitBreaker

NewCircuitBreaker returns a new CircuitBreaker.

func (*CircuitBreaker) ServeHTTP

func (cb *CircuitBreaker) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Logger

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

Logger is a middleware handler that logs the request as it goes in and the response as it goes out.

func NewLogger

func NewLogger(file string) *Logger

NewLogger returns a new Logger instance.

func (*Logger) Close

func (l *Logger) Close()

Close closes the logger (i.e. the file).

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Routes

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

Routes holds the gorilla mux routes (for the API & co).

func NewRoutes

func NewRoutes(router *mux.Router) *Routes

NewRoutes return a Routes based on the given router.

func (*Routes) ServeHTTP

func (router *Routes) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type WebsocketProxy

type WebsocketProxy struct {
	// Backend returns the backend URL which the proxy uses to reverse proxy
	// the incoming WebSocket connection. Request is the initial incoming and
	// unmodified request.
	Backend func(*http.Request) *url.URL

	// Upgrader specifies the parameters for upgrading a incoming HTTP
	// connection to a WebSocket connection. If nil, DefaultUpgrader is used.
	Upgrader *websocket.Upgrader

	//  Dialer contains options for connecting to the backend WebSocket server.
	//  If nil, DefaultDialer is used.
	Dialer *websocket.Dialer
}

WebsocketProxy is an HTTP Handler that takes an incoming WebSocket connection and proxies it to another server.

func NewProxy

func NewProxy(target *url.URL) *WebsocketProxy

NewProxy returns a new Websocket reverse proxy that rewrites the URL's to the scheme, host and base path provider in target.

func (*WebsocketProxy) ServeHTTP

func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler that proxies WebSocket connections.

type WebsocketUpgrader

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

WebsocketUpgrader holds Websocket configuration.

func NewWebsocketUpgrader

func NewWebsocketUpgrader(rr *roundrobin.RoundRobin) *WebsocketUpgrader

NewWebsocketUpgrader returns a new WebsocketUpgrader.

func (*WebsocketUpgrader) ServeHTTP

func (u *WebsocketUpgrader) ServeHTTP(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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