Documentation ¶
Overview ¶
Package httpidletimeout implements an HTTP middleware that triggers after a given timeout.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware implements an HTTP middleware that triggers after an idle timeout (as in time since the last request completed). To initialize a Middleware, use New() passing the idle timeout, start it via Start() and finally use Wait() to wait for the idle timeout to trigger. To exit cleanly, Cancel() should be called at some point after Start() to free the resources associated with the Middlware (e.g. with a defer after New()).
func New ¶
func New(timeout time.Duration, opts ...Option) *Middleware
New returns a new Middleware which will timeout after the given duration. See Middleware for more information.
func (*Middleware) Cancel ¶
func (m *Middleware) Cancel()
Cancel makes the Middleware stop triggering timeouts after its timeout interval. An stopped Middleware can't be restarted again.
func (*Middleware) Handler ¶
func (m *Middleware) Handler(next http.Handler) http.Handler
Handler returns a handler wrapped by the Middleware
func (*Middleware) HandlerFunc ¶
func (m *Middleware) HandlerFunc(next http.HandlerFunc) http.Handler
HandlerFunc is a shorthand for wrapping http.HandlerFunc handlers
func (*Middleware) Start ¶
func (m *Middleware) Start()
Start makes the Middleware start counting towards the idle timeout. After Start(), Cancel() should be called at some point.