middleware

package
v0.0.0-...-f1dd9c7 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

middleware of the HTTP server The logger middleware adds logging support to every request

middleware of the HTTP server

middleware of the HTTP server The pre-flight middleware adds common response headers to requests

middleware of the HTTP server The recovery middleware attempts to recover from panics that occur within the request execution chain

middleware of the HTTP server Checks for and normalizes an API version for each request

Index

Constants

View Source
const (
	AcceptHeaderPattern = "application/vnd.soulcycle.fed.v(\\d+(?:\\.\\d+)?)\\+json"
	VersionPattern      = "\\d+\\.\\d+"
)
View Source
const (
	// String defining the format of the logger's date output
	LogDateFormat = "01/02 - 15:04:05"
)

Variables

View Source
var (
	AcceptHeaderRegex *regexp.Regexp // Regex to check for valid Accept headers
	VersionRegex      *regexp.Regexp // Regex to get version from Accept header

)
View Source
var (
	// Stream to write to for stdout
	// NOTE: Pattern used to allow for test-based overrides of stdout
	OutputStream *os.File = os.Stdout
)

Functions

func NewMiddleware

func NewMiddleware() alice.Chain

NewMiddleware creates and returns a new instance of a middleware chain

Types

type Logger

type Logger struct {
	Log *log.Logger
}

Struct representing logger middleware

func NewLogger

func NewLogger() Logger

NewLogger creates and returns a new instance of logger middleware

func (Logger) Handler

func (m Logger) Handler(next http.Handler) http.Handler

Handler handles the processing of the request The pre-flight middleware handler adds logging support to every request

type Preflight

type Preflight struct{}

Struct representing pre-flight middleware

func NewPreflight

func NewPreflight() Preflight

NewPreflight creates and returns a new instance of pre-flight middleware

func (Preflight) Handler

func (m Preflight) Handler(next http.Handler) http.Handler

Handler handles the processing of the request The pre-flight middleware handler adds common response headers to requests

type Recovery

type Recovery struct{}

Struct representing recovery middleware

func NewRecovery

func NewRecovery() Recovery

NewRecovery creates and returns a new instance of recovery middleware

func (Recovery) Handler

func (m Recovery) Handler(next http.Handler) http.Handler

Handler handles the processing of the request The recovery middleware handler attempts to recover from any panics that occur within the request execution chain

type Version

type Version struct{}

Struct representing version middleware

func NewVersion

func NewVersion() Version

NewVersion creates and returns a new instance of version middleware

func (Version) Handler

func (m Version) Handler(next http.Handler) http.Handler

Handler handles the processing of the request The version middleware handler checks for an API version within the `Accept` header and parses it to set the version of the current request

Jump to

Keyboard shortcuts

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