middlewares

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const TokenHeader = "X-Algo-API-Token"

TokenHeader defines the http header that includes the auth token

Variables

This section is empty.

Functions

func Auth

func Auth(log logging.Logger, apiToken string) func(http.Handler) http.Handler

Auth takes a logger and an api token and return a middleware function that satisfies the gorilla middleware interface.

func CORS

func CORS(h http.Handler) http.Handler

CORS adds the CORS headers to every response

func Logger

func Logger(log logging.Logger) func(http.Handler) http.Handler

Logger is a gorilla/mux middleware to add log to the API

Types

type LoggingResponseWriter

type LoggingResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

LoggingResponseWriter will encapsulate a standard ResponseWriter with a copy of its statusCode

func ResponseWriterWrapper

func ResponseWriterWrapper(w http.ResponseWriter) *LoggingResponseWriter

ResponseWriterWrapper is supposed to capture statusCode from ResponseWriter

func (*LoggingResponseWriter) WriteHeader

func (lrw *LoggingResponseWriter) WriteHeader(code int)

WriteHeader adds a header to each response

Jump to

Keyboard shortcuts

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