Documentation
¶
Overview ¶
Package handler exposes cheshmhayash's HTTP API. Routes are registered on the stdlib http.ServeMux (Go 1.22+ pattern syntax with method+path).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MCPMux ¶ added in v1.0.1
func MCPMux( mcpHandler http.Handler, authn *auth.Authenticator, mcpKeys []auth.KeyMatcher, logger *slog.Logger, ) http.Handler
MCPMux builds the HTTP handler for the MCP server (`cheshmhayash mcp --http`): a liveness probe at /healthz, the MCP Streamable HTTP transport at /mcp, and the RFC 9728 OAuth metadata endpoints. It shares the dashboard's CORS + request-logging wrappers.
authn is optional (nil ⇒ no auth). mcpKeys, when non-empty, gates /mcp with bearer-token auth independently of authn — MCP keys work even with OIDC disabled. The well-known metadata is registered only when auth.mcp_oauth is enabled.
func Mux ¶
func Mux( mgr *natsx.Manager, cache *natsx.OverviewCache, opts Options, logger *slog.Logger, authn *auth.Authenticator, ) http.Handler
Mux returns a ServeMux with /healthz and the parts that opts selects: the /api routes and the static-file SPA fallback at /. The HTTP MCP transport is served by `cheshmhayash mcp --http`; see MCPMux.
cache is optional; when nil, /api/jsm/.../overview falls back to a live NATS call on every request and /overview/stream returns 503.
authn is optional. When non-nil and Enabled, /api/auth/* endpoints are registered and all /api/* routes are wrapped in the session-check middleware.
Types ¶
type Options ¶ added in v1.1.0
type Options struct {
// API registers /api/admin, /api/jsm, /api/version and /api/auth.
API bool
// StaticDir, when non-empty, serves the built SPA from that directory
// with an index.html fallback at /.
StaticDir string
}
Options selects which parts of the dashboard the Mux serves. The serve command builds it from its --components flag, so one image can run the API, the SPA, or both.