middleware

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigFromContext

func ConfigFromContext(ctx context.Context) (*config.Config, bool)

ConfigFromContext 从ctx中获取model.Repo

func InjectConfig

func InjectConfig(conf *config.Config) rest.Middleware

InjectConfig 注入*config.Config

func InjectLogger

func InjectLogger(logger logger.Logger) rest.Middleware

InjectLogger 注入logger.Logger

func InjectRepo

func InjectRepo(repo model.Repo) rest.Middleware

InjectRepo 注入model.Repo

func LoggerFromContext

func LoggerFromContext(ctx context.Context) (logger.Logger, bool)

LoggerFromContext 从ctx中获取model.Repo

func RepoFromContext

func RepoFromContext(ctx context.Context) (model.Repo, bool)

RepoFromContext 从ctx中获取model.Repo

Types

type CloseMiddleware

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

CloseMiddleware cancel context when timeout

func NewCloseMiddleware

func NewCloseMiddleware(log logger.Logger) *CloseMiddleware

NewCloseMiddleware create middleware

func (*CloseMiddleware) MiddlewareFunc

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

MiddlewareFunc makes CloseMiddleware implement the Middleware interface.

type LimiterMiddleware

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

LimiterMiddleware cancel context when timeout

func Limiter

func Limiter(logger logger.Logger, limiter *config.Limiter) *LimiterMiddleware

Limiter create timeout middleware with duration

func NewLimiterMiddleware

func NewLimiterMiddleware(logger logger.Logger, max int64, ttl time.Duration) *LimiterMiddleware

NewLimiterMiddleware create a simple limiter

func (*LimiterMiddleware) MiddlewareFunc

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

MiddlewareFunc makes LimiterMiddleware implement the Middleware interface.

type TimeoutMiddleware

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

TimeoutMiddleware cancel context when timeout

func NewTimeoutMiddleware

func NewTimeoutMiddleware(timeout time.Duration) *TimeoutMiddleware

NewTimeoutMiddleware create timeout middleware with duration

func (*TimeoutMiddleware) MiddlewareFunc

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

MiddlewareFunc makes TimeoutMiddleware implement the Middleware interface.

Jump to

Keyboard shortcuts

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