limits

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestStartTime added in v0.4.4

func RequestStartTime(ctx context.Context) (time.Time, bool)

RequestStartTime returns the time the request started, if set by the Limiter middleware.

Types

type Limiter

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

Limiter adds request timeouts to HTTP handlers.

func New

func New(maxRequestDuration string) (*Limiter, error)

New creates a new Limiter, which adds the given request timeout to HTTP handlers. The string maxRequestDuration must be parseable as a positive time.Duration; e.g., "5m", "30s".

func (*Limiter) AddRequestTimeout

func (l *Limiter) AddRequestTimeout(next http.Handler) http.Handler

AddRequestTimeout wraps the given handler in a new one that cancels the request context after the duration specified in the limiter.

Jump to

Keyboard shortcuts

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