server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

server

server runs related graceful HTTP listeners together. If one listener exits, the others are cancelled and shut down.

err := server.Run(ctx,
    server.Listener{
        Address: ":8080",
        Handler: application,
        Logger:  logger.With("server", "application"),
    },
    server.Listener{
        Address: ":9090",
        Handler: management,
        Logger:  logger.With("server", "management"),
    },
)

Configure the logger before constructing each Listener; server forwards it unchanged. Use Listener.Options with grace.With... options when a listener needs different timeouts or limits.

Documentation

Overview

Package server runs related HTTP listeners with coordinated graceful shutdown.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, listeners ...Listener) error

Run serves every listener and stops the others when one returns.

Types

type Listener

type Listener struct {
	Address string
	Handler http.Handler
	Logger  *slog.Logger
	Options []grace.Option
}

Listener describes one HTTP listener managed by Run.

Jump to

Keyboard shortcuts

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