middleware

package
v0.0.0-...-39cffea Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultResponseInterceptor

func SetDefaultResponseInterceptor(r Recorder)

SetDefaultResponseInterceptor for http handler response

Types

type Middleware

type Middleware func(http.HandlerFunc) http.HandlerFunc

Middleware is a chainable preprocessor for Endpoint

func Chain

func Chain(first Middleware, others ...Middleware) Middleware

Chain is a helper function for composing middlewares.

func RecoverWithTrace

func RecoverWithTrace(name string) Middleware

RecoverWithTrace middleware is a RecoverMiddleware wraps with a trace handler

func Trace

func Trace(name string) Middleware

Trace will create a trace handler middleware

func (Middleware) HandlerFunc

func (m Middleware) HandlerFunc(next http.HandlerFunc) http.HandlerFunc

HandlerFunc will return the HandlerFunc of the middleware

type Recorder

type Recorder interface {
	Record(ctx context.Context, statistics Statistics)
}

Recorder for http handler response status & body size

func NewLogRecorder

func NewLogRecorder() Recorder

NewLogRecorder for log purpose

func NewMultiRecorder

func NewMultiRecorder(recorders ...Recorder) Recorder

NewMultiRecorder will chain MultiRecorder

type Statistics

type Statistics struct {
	Status   int
	BodySize int
}

Statistics for http handler response

Jump to

Keyboard shortcuts

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