httpserver

package
v1.24.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerNameDefault = "server"
	ServerNameDebug   = "debug"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

func NewHTTPServer

func NewHTTPServer(name string, logger *slog.Logger, conf config.HTTP, fnHandler *http.ServeMux) *Server

NewHTTPServer creates a new Server instance configured with the given name, logger and HTTP configuration. fnHandler is registered as the HTTP handler for the server. The returned server can optionally serve TLS depending on the configuration.

func (*Server) GetCertificateFunc added in v1.17.0

func (s *Server) GetCertificateFunc() func(*tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificateFunc returns a function compatible with tls.Config.GetCertificate. It serves the currently loaded TLS certificate and allows hot reloading.

func (*Server) Listen

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

Listen starts the HTTP server and blocks until the context is cancelled. It configures TLS if enabled and performs graceful shutdown when the context signals cancellation.

func (*Server) Reload added in v1.17.0

func (s *Server) Reload() error

Reload loads the TLS certificate from disk and updates the server's in-memory certificate. It does nothing if TLS support is disabled.

Jump to

Keyboard shortcuts

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