httpserver

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httpserver is the HTTP server the API gateway and the Services' endpoints serve with: HTTP/1.1 and h2c, and a Shutdown that stops even when its ctx has already ended (#1034, #1117).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

Server is an http.Server speaking HTTP/1.1 and h2c. Callers may set its fields, such as ConnState, ConnContext, HTTP2 or TLSConfig, before serving, but not BaseContext, which Shutdown uses to end every request. Only Serve and ServeTLS track their listeners' close errors, and only Shutdown ends the requests' contexts; ListenAndServe and Close are http.Server's own.

func New

func New(name string, h http.Handler, log *slog.Logger) *Server

New returns a Server for h. name names it in the line Shutdown logs when it closes connections by force, such as "API gateway".

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve serves on l until Shutdown or Close.

func (*Server) ServeTLS

func (s *Server) ServeTLS(l net.Listener, certFile, keyFile string) error

ServeTLS serves TLS on l until Shutdown or Close.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown stops the Server. It drains within ctx; if ctx ends first, the connections still open are closed by force, which is the normal end of a shutdown rather than an error, and one Info line says so. Then it ends every request's context, so connections the server handed over close as their handlers return. It reports only a real failure to stop, such as a listener that failed to close.

Jump to

Keyboard shortcuts

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