server

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host            string
	Port            int
	ShutdownTimeout time.Duration
	CORSOrigins     []string
	EnableUI        bool
	MaxBodySize     int64 // bytes
}

Config holds the HTTP server configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible production defaults.

type Server

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

Server is the top-level HTTP server for Faucet. It owns the Chi router, the connector registry, configuration store, and authentication service.

func New

func New(cfg Config, registry *connector.Registry, store *config.Store, authSvc *service.AuthService, logger *slog.Logger) *Server

New creates a new Server, wires up all routes and middleware, and returns it ready to listen. Call ListenAndServe to start accepting connections.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the HTTP server and blocks until a SIGINT or SIGTERM is received. It then performs a graceful shutdown, draining in-flight requests before closing all database connections.

func (*Server) Router

func (s *Server) Router() chi.Router

Router returns the underlying Chi router, useful for testing.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler, delegating to the router.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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