Documentation ¶
Index ¶
- func ConfigFromContext(ctx context.Context) (*config.Config, bool)
- func InjectConfig(conf *config.Config) rest.Middleware
- func InjectLogger(logger logger.Logger) rest.Middleware
- func InjectRepo(repo model.Repo) rest.Middleware
- func LoggerFromContext(ctx context.Context) (logger.Logger, bool)
- func RepoFromContext(ctx context.Context) (model.Repo, bool)
- type CloseMiddleware
- type LimiterMiddleware
- type TimeoutMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigFromContext ¶
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 LoggerFromContext ¶
LoggerFromContext 从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 ¶
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.