handler

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 13 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
}

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.

Jump to

Keyboard shortcuts

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