server

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package server is fort-core's local HTTP/WS API (backlog AO-011): /health, graceful shutdown, and the event/command surface the fort-ui module consumes (the live-feed and command routes are added in Phase 3 on top of this).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObserveRequests added in v0.13.0

func ObserveRequests(next http.Handler, observer RequestObserver) http.Handler

ObserveRequests adds one canonical correlation ID and emits a payload-free completion event. It is shared by the local listener and the relay mux.

Types

type Deps

type Deps struct {
	Config          config.Config
	Engine          *engine.Engine
	Store           *store.Store
	Logger          *slog.Logger
	RequestObserver RequestObserver
	// Mount optionally adds extra routes (the fort-ui module, wired in by
	// cmd/fort). core never imports ui — the closure is provided from outside,
	// preserving the core !-> ui seam.
	Mount func(*http.ServeMux)
}

Deps are the server's collaborators. All are optional for the bare /health server; richer routes require engine + store.

type RequestEvent added in v0.13.0

type RequestEvent struct {
	ID       string
	Method   string
	Path     string
	Status   int
	Duration time.Duration
}

RequestEvent is the payload-free ingress trace emitted after one HTTP request. Path excludes the query string.

type RequestObserver added in v0.13.0

type RequestObserver func(RequestEvent)

type Server

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

Server serves the fort-core API.

func New

func New(d Deps) *Server

New builds a server.

func (*Server) Handler

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

Handler returns the HTTP handler (exposed for tests).

func (*Server) Run

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

Run starts the server and blocks until ctx is canceled, then shuts down gracefully.

Jump to

Keyboard shortcuts

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