server

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package server provides an HTTP server with sane defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is a wrapper around an http.Server that attempts to shutdown gracefully. Unlike http.Server, this implementation does not return an error if the server is shutdown cleanly.

func New

func New(port string, h http.Handler) Server

New returns a Server that listens on the given port on any interface (0.0.0.0:PORT). Read, write, and idle timeouts are set to sane values.

func (Server) Addr

func (s Server) Addr() string

Addr returns the full address that the server is configured to listen on.

func (Server) ListenAndServe

func (s Server) ListenAndServe(ctx context.Context) error

ListenAndServe listens for connections on interface 0.0.0.0 at the port provided to New. If the provided context is canceled, the server will attempt to gracefully shutdown. The returned error will only be non-nil if the server exits abnormally or fails to shutdown in time.

Jump to

Keyboard shortcuts

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