xtimeout

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConstructor

func NewConstructor(o Options) func(http.Handler) http.Handler

NewConstructor returns an Alice-style constructor that enforces a timeout for any handler it decorates. If timeout is nonpositive, a constructor is returned that does no decoration. If timedOut is nil, a default timedOut handler is used that just sets an http.StatusGatewayTimeout response code.

Types

type Options

type Options struct {
	// Timeout is the time allowed for the decorated handler's ServeHTTP method to run.
	// If unset or nonpositive, no decoration is performed.
	Timeout time.Duration

	// TimedOut is the optional http.Handler that is executed with the original http.Request
	// whenever a timeout occurs.  If unset, a default handler is used that simply sets the response
	// code to http.StatusGatewayTimeout.
	TimedOut http.Handler
}

Options holds the set of configurable options for a timeout constructor.

Jump to

Keyboard shortcuts

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