listener

package
v0.0.0-...-ba6f454 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPListener

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

func New

func New(opts ...Option) *HTTPListener

func (*HTTPListener) Listen

func (s *HTTPListener) Listen(ctx context.Context, port int, handler http.Handler) error

type Metrics

type Metrics interface {
	Increment(key string)
}

type Option

type Option func(*options)

func WithIdleTimeout

func WithIdleTimeout(timeout time.Duration) Option

WithIdleTimeout sets the maximum amount of time to wait for the next request.

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger enables logging for MW.

func WithMW

func WithMW(mw ...func(handler http.Handler) http.Handler) Option

WithMW sets middleware. Order of middleware: third(second(first(handler))) The last one will be called first for any incoming request.

func WithMetrics

func WithMetrics(metrics Metrics) Option

WithMetrics enables metrics aggregation.

func WithReadTimeout

func WithReadTimeout(timeout time.Duration) Option

WithReadTimeout sets the maximum duration for reading the entire request, including the body.

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

WithShutdownTimeout sets the maximum duration for graceful shutdown (0 is no timeout).

func WithWriteTimeout

func WithWriteTimeout(timeout time.Duration) Option

WithWriteTimeout sets the maximum duration before timing out writes of the response.

Jump to

Keyboard shortcuts

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