server

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package server wires TableX's HTTP layer together: it builds the renderer, session manager, rate limiter and handlers, assembles the middleware chain and route table, serves embedded static assets, and manages graceful startup and shutdown (closing every session pool on the way out).

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 the running TableX HTTP application.

func New

func New(cfg config.Config, log *slog.Logger, version string) (*Server, error)

New constructs a Server from resolved config. It parses templates and loads icons up front so any template error surfaces at startup, not mid-request.

func (*Server) Handler

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

Handler returns the fully-wrapped HTTP handler (middleware chain + router), used by httptest in integration tests.

func (*Server) Listen

func (s *Server) Listen() (net.Listener, error)

Listen binds the configured address and returns the listener, so the caller can log the ACTUAL bound address (which differs from cfg.Listen for a ":0" ephemeral port) only after the bind has succeeded — a bind failure surfaces here instead of after an already-emitted "listening" line. Pair with Serve.

func (*Server) Serve

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

Serve serves HTTP(S) on ln and blocks until the server stops. TLS is used when configured. http.ErrServerClosed (from a clean Shutdown) is success.

func (*Server) Shutdown

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

Shutdown drains in-flight requests, then closes every session's DB pools so credentials don't linger. It is safe to call more than once.

If the drain times out (a handler stuck past the ctx budget), it cancels every in-flight request context and force-closes the HTTP server so those handlers unwind, THEN still closes all session pools. Skipping the pool close on a timeout would leak OS-level DB connections and keep every session's credentials reachable in server-side memory — sessions.Shutdown() is the only server-exit path that closes all pools and drops the session-store references that hold them.

func (*Server) TLS

func (s *Server) TLS() bool

TLS reports whether the server serves HTTPS directly.

Directories

Path Synopsis
Package handlers implements TableX's HTTP handlers — one file per feature area (auth, home, server, database, table, sql, navigation).
Package handlers implements TableX's HTTP handlers — one file per feature area (auth, home, server, database, table, sql, navigation).

Jump to

Keyboard shortcuts

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