handler

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	// Tap, when non-nil and API is on, registers the live tap under
	// /api/tap.
	Tap *Tap
}

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.

type Tap added in v1.3.0

type Tap struct {
	// Allow lists the subject patterns a tap may subscribe to; empty
	// allows any subject.
	Allow []string
	// MaxRate is the most messages per second sent to one browser.
	MaxRate int
	// MaxDuration closes a tap after this long.
	MaxDuration time.Duration
	// MaxTaps is the most taps this process serves at a time.
	MaxTaps int
	// ReadOnlyAllowed lets readonly users tap when auth is on; otherwise
	// only admins may.
	ReadOnlyAllowed bool
	// Chains builds the decoder chain for one tap; force is the protobuf
	// type for every payload, or "".
	Chains func(force string) codec.Chain
}

Tap is the configuration of the live tap. A nil *Tap in Options leaves the tap routes unregistered.

Jump to

Keyboard shortcuts

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