package server // import "github.com/anulum/director-ai/gateway/internal/server"
Package server wires the gateway middleware chain: request-ID → audit → auth →
rate limit → proxy. The chain is deliberately short; every piece can be tested
in isolation.
FUNCTIONS
func RequestID(r *http.Request) string
RequestID returns the request ID attached by requestIDMiddleware. Empty when
the middleware has not run on this request (e.g., in a unit test exercising
a handler directly).
func Run(cfg *config.Config, auditLogger *audit.Logger) error
Run starts an HTTP server on the configured listen address and blocks until
the server exits.
TYPES
type Components struct {
Config *config.Config
Auth *auth.Middleware
Rate *ratelimit.Limiter
Proxy *proxy.Client
Audit *audit.Logger
Scoring *scoring.Client
Risk *risk.Middleware
Handler http.Handler
}
Components bundles the wired middleware so callers can assemble a server
once and reuse it for tests.
func Build(cfg *config.Config, auditLogger *audit.Logger) (*Components, error)
Build builds the middleware chain from a resolved config. “auditWriter“,
when non-nil, overrides the file sink — useful in tests that capture log
output.