middleware

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package middleware contains various http middlewares.

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefaults = Config{
	Host:                 ":1874",
	Backend:              "postgres",
	ShutdownTimeout:      30 * time.Second,
	DefaultMaxJobTimeout: 10 * time.Minute,
	DefaultMaxRetries:    10,
	InvalidateInterval:   15 * time.Second,
	ReapInterval:         10 * time.Minute,
}
View Source
var ConfigKey = contextKey("config")

Functions

func Time

func Time(t internal.TimeProvider, tick internal.Ticker) func(next http.Handler) http.Handler

Types

type Config

type Config struct {
	Host            string        `json:"host"`
	DevLog          bool          `json:"dev_log" envconfig:"dev_log"`
	DebugLog        bool          `json:"debug_log" envconfig:"debug"`
	Backend         string        `json:"backend" envconfig:"backend"`
	ShutdownTimeout time.Duration `json:"shutdown_timeout" envconfig:"shutdown_timeout"`

	DefaultMaxJobTimeout time.Duration `json:"default_max_job_timeout" envconfig:"default_max_job_timeout"`
	DefaultMaxRetries    int           `json:"default_max_retries" envconfig:"default_max_retries"`

	InvalidateInterval time.Duration `json:"invalidate_interval,omitempty" envconfig:"invalidate_interval"`
	ReapInterval       time.Duration `json:"reap_interval,omitempty" envconfig:"reap_interval"`
	ReapAge            time.Duration `json:"reap_age,omitempty" envconfig:"reap_age"`
	ReapMax            int           `json:"reap_max,omitempty" envconfig:"reap_max"`

	Logger    *logger.Logger `json:"-"`
	LogOutput io.Writer      `json:"-"`
}

func ConfigFromContext

func ConfigFromContext(ctx context.Context) Config

func NewConfig

func NewConfig() Config

func (*Config) ResetLogOutput

func (c *Config) ResetLogOutput(out io.Writer)

Jump to

Keyboard shortcuts

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