httpserver

package
v1.54.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package httpserver builds the HTTP transport every service in this repo runs on: CORS, access logging with correlation IDs, and the Serve/Shutdown lifecycle pkg/boot.Service expects. A service package supplies only its own routes and gets the rest for free instead of rebuilding http.Server and its middleware chain by hand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name      string
	Component string
	Address   string

	CORS     config.CORSConfig
	Timeouts config.HTTPDefaults

	Registration
}

Config is what pkg/boot.Boot builds from a Registration plus what only the platform layer decides: name, listen address, and the CORS/timeout defaults every HTTP server in this repo shares.

type Registration

type Registration struct {
	// ServiceTokenHeader, if set, is added to CORS's allowed headers so a
	// browser-based service-to-service caller can present it; leave empty
	// if the service takes no service-token header.
	ServiceTokenHeader string

	// SetupRoutes registers the service's own handlers on mux. Required.
	SetupRoutes func(mux *http.ServeMux)

	// Closers are closed, in order, after the HTTP server has shut down.
	Closers []io.Closer
}

Registration is what a service provides: its routes, never the transport around them.

type Server

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

func New

func New(cfg Config) *Server

func (*Server) Address

func (s *Server) Address() string

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the fully-wrapped handler (CORS, then access logging) — an escape hatch for tests that drive it directly instead of over a real listener.

func (*Server) Logger

func (s *Server) Logger() *logrus.Entry

func (*Server) Name

func (s *Server) Name() string

func (*Server) Serve

func (s *Server) Serve() error

func (*Server) Shutdown

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

Jump to

Keyboard shortcuts

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