Categorygithub.com/diamondburned/listener
modulepackage
0.0.0-20230916085943-c7c2ec380bbc
Repository: https://github.com/diamondburned/listener.git
Documentation: pkg.go.dev

# README

Deprecated!

Please use hserve instead.


listener

A small library to provide TCP+Unix listener functions as well as graceful shutdowns.

Usage

server := http.Server{
	Addr:    "unix:///tmp/server.sock",
	Handler: handler,
}

// This function will block until SIGINT is received or HTTP servers error out.
if err := listener.HTTPListenAndServe(&server); err != nil {
	log.Fatalln("Failed to serve HTTP:", err)
}

# Functions

HTTPListenAndServe listens and serves HTTP until a SIGINT is received.
HTTPListenAndServeCtx listens to the address set in http.Server and serves HTTP.
Listen calls ListenWithConfig with the DefaultListenConfig.
ListenWithConfig listens for incoming connections using the given address string.
MustHTTPListenAndServe is HTTPListenAndServe that log.Fatals on an error.
MustHTTPListenAndServeCtx is HTTPListenAndServeCtx that log.Fatals on an error.

# Variables

DefaultListenConfig is the default ListenConfig used for Listen().
HTTPShutdownTimeout is the timeout to wait when shutting down HTTP.