middleware

package
v0.0.0-...-e285db0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TokenRequestID = tokenRequestID("scarf.middleware.request_id")

TokenRequestID is the unique token to which the current request's unique ID is written to the request context.

Functions

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID retrieves the current request's unique ID. If no request ID is registered with this context, the empty string is returned.

func WrapServerStream

func WrapServerStream(ss grpc.ServerStream, key, value interface{}) grpc.ServerStream

Types

type ErrorFactory

type ErrorFactory func(error) error

type LoggingConfigFunc

type LoggingConfigFunc func(m *LoggingMiddleware)

func WithLoggingClock

func WithLoggingClock(clock glock.Clock) LoggingConfigFunc

type LoggingMiddleware

type LoggingMiddleware struct {
	Logger    nacelle.Logger     `service:"logger"`
	Decorator *logging.Decorator `service:"logger-decorator"`
	// contains filtered or unexported fields
}

func NewLogging

func NewLogging(configs ...LoggingConfigFunc) *LoggingMiddleware

NewLogging creates middleware that logs incoming requests and the status of the response after the request is handled.

func (*LoggingMiddleware) ApplyStream

func (*LoggingMiddleware) ApplyUnary

func (*LoggingMiddleware) Init

func (m *LoggingMiddleware) Init() error

type PanicErrorFactory

type PanicErrorFactory func(interface{}) error

type RecoverConfigFunc

type RecoverConfigFunc func(m *RecoverMiddleware)

func WithRecoverErrorFactory

func WithRecoverErrorFactory(factory PanicErrorFactory) RecoverConfigFunc

func WithRecoverLogAllGoroutines

func WithRecoverLogAllGoroutines(logAllGoroutines bool) RecoverConfigFunc

func WithRecoverStackBufferSize

func WithRecoverStackBufferSize(stackBufferSize int) RecoverConfigFunc

type RecoverMiddleware

type RecoverMiddleware struct {
	Logger    nacelle.Logger     `service:"logger"`
	Decorator *logging.Decorator `service:"logger-decorator"`
	// contains filtered or unexported fields
}

func NewRecovery

func NewRecovery(configs ...RecoverConfigFunc) *RecoverMiddleware

NewRecovery creates middleware that captures panics from the handler and converts them to gRPC error responses. The value of the panic is logged at error level.

func (*RecoverMiddleware) ApplyStream

func (*RecoverMiddleware) ApplyUnary

func (*RecoverMiddleware) Init

func (m *RecoverMiddleware) Init() error

type RequestIDConfigFunc

type RequestIDConfigFunc func(m *RequestIDMiddleware)

func WithRequestIDErrorFactory

func WithRequestIDErrorFactory(factory ErrorFactory) RequestIDConfigFunc

func WithRequestIDGenerator

func WithRequestIDGenerator(generator RequestIDGenerator) RequestIDConfigFunc

type RequestIDGenerator

type RequestIDGenerator func() (string, error)

type RequestIDMiddleware

type RequestIDMiddleware struct {
	Logger    nacelle.Logger     `service:"logger"`
	Decorator *logging.Decorator `service:"logger-decorator"`
	// contains filtered or unexported fields
}

func NewRequestID

func NewRequestID(configs ...RequestIDConfigFunc) *RequestIDMiddleware

NewRequestID creates middleware that generates a unique ID for the request. The request ID is added to the context and is made available by the GetRequestID function.

func (*RequestIDMiddleware) ApplyStream

func (*RequestIDMiddleware) ApplyUnary

func (*RequestIDMiddleware) Init

func (m *RequestIDMiddleware) Init() error

Jump to

Keyboard shortcuts

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