middleware

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHTTPS

func IsHTTPS(r *rest.Request) bool

IsHTTPS returns true if the request is using https protocol or false otherwise

func IsProxiedHTTPS

func IsProxiedHTTPS(r *rest.Request) bool

IsProxiedHTTPS returns true if the original request is using https protocol or false otherwise

func IsUsingSecureConnection

func IsUsingSecureConnection(r *rest.Request) bool

IsUsingSecureConnection returns true if the request is using secure connection or false otherwise

Types

type AuthMiddleware

type AuthMiddleware struct {
	Authenticator auth.Authenticator
}

AuthMiddleware provides a generic authentication middleware On failure, a 401 HTTP response is returned. On success, the wrapped middleware is called.

func (*AuthMiddleware) MiddlewareFunc

func (mw *AuthMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc

MiddlewareFunc returns a go-json-rest HTTP Handler function, wrapping calls to the provided HandlerFunc

type CheckRequest

type CheckRequest struct {
	// Defines a function that, given a request, determines if the request is secure or should be redirected.
	// Criteria may include, for example, scheme, X-Forward* headers, URL paths, etc. If unset, a default
	// criteria is applied, checking the request's scheme and TLS configuration
	IsSecure func(r *rest.Request) bool
	// When developing, various options can cause unwanted effects (e.g., usually testing happens on localhost with
	// http, not https, etc.). The following flag can set to true in a development environment to disable checks
	// and redirection. Default is false (i.e., it is enabled)
	Disabled bool
}

CheckRequest defines the request validation configuration used by RequireHTTPS middleware

type LoggingMiddleware

type LoggingMiddleware struct{}

LoggingMiddleware logs information about the request

func (*LoggingMiddleware) MiddlewareFunc

func (mw *LoggingMiddleware) MiddlewareFunc(h rest.HandlerFunc) rest.HandlerFunc

MiddlewareFunc logs information about the request after it completes

type RequestIDMiddleware

type RequestIDMiddleware struct{}

RequestIDMiddleware appends a request ID header to incoming request for log tracing across services

func (*RequestIDMiddleware) MiddlewareFunc

func (mw *RequestIDMiddleware) MiddlewareFunc(h rest.HandlerFunc) rest.HandlerFunc

MiddlewareFunc makes RequestIDMiddleware implement the Middleware interface.

type RequireHTTPS

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

RequireHTTPS provide HTTP middleware to ensure requests are received over secure communication. By default, all requests using HTTP are redirected to the corresponding HTTPS URL.

func NewRequireHTTPS

func NewRequireHTTPS(checkConfig CheckRequest) *RequireHTTPS

NewRequireHTTPS creates a new middleware with the given checks configured

func (*RequireHTTPS) MiddlewareFunc

func (secure *RequireHTTPS) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc

MiddlewareFunc returns a go-json-rest HTTP Handler function, wrapping calls to the provided HandlerFunc

type SetupHandler

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

SetupHandler structure for filtering REST calls during setup of microservice

func NewSetupHandler

func NewSetupHandler() *SetupHandler

NewSetupHandler creates a new SetupHandler

func (*SetupHandler) ServeHTTP

func (h *SetupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serve http or return 503 while setup is still in progress

func (*SetupHandler) SetError

func (h *SetupHandler) SetError(err error)

SetError for handler

func (*SetupHandler) SetHandler

func (h *SetupHandler) SetHandler(handler http.Handler)

SetHandler creates handler

Jump to

Keyboard shortcuts

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