router

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 29 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 router contains API routing logic

Package router contains API routing logic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MetricTelemetryMiddleware

func MetricTelemetryMiddleware(metrics *telemetry.Metrics, options ...MiddlewareOption) func(huma.Context, func(huma.Context))

func NewHumaAPI

func NewHumaAPI(
	cfg *config.Config,
	mux *http.ServeMux,
	metrics *telemetry.Metrics,
	versionInfo *arv0.VersionBody,
	uiHandler http.Handler,
	authnProvider auth.AuthnProvider,
	routeOpts *RouteOptions,
	schemaNamer func(reflect.Type, string) string,
) (huma.API, error)

NewHumaAPI creates a new Huma API with all routes registered. Returns an error when RegisterRoutes rejects the supplied RouteOptions (e.g. Stores missing).

Note: authz is handled at the DB/service layer, not at the API layer.

func RegisterRoutes

func RegisterRoutes(
	api huma.API,
	cfg *config.Config,
	metrics *telemetry.Metrics,
	versionInfo *arv0.VersionBody,
	opts *RouteOptions,
) error

RegisterRoutes registers all API routes under /v0. Required dependencies (RouteOptions itself, Stores) trigger an error rather than a silent skip so a misconfigured boot fails visibly.

Types

type MiddlewareOption

type MiddlewareOption func(*middlewareConfig)

func WithSkipPaths

func WithSkipPaths(paths ...string) MiddlewareOption

WithSkipPaths allows skipping instrumentation for specific paths

type RouteOptions added in v0.1.21

type RouteOptions struct {
	// Stores is the per-kind v1alpha1store map that drives the
	// generic CRUD handlers. Tagged artifacts expose
	// `/v0/{plural}/{name}/{tag}?namespace={ns}`; mutable objects expose
	// `/v0/{plural}/{name}?namespace={ns}`. Namespace defaults to
	// "default"; `?namespace=all` widens list scope across every
	// namespace.
	// REQUIRED — RegisterRoutes errors when this is nil/empty.
	Stores Stores

	// DeploymentLogResolver supports the Deployment logs subresource. Adapter
	// Apply/Remove side effects are owned by the Deployment controller, not by
	// CRUD hook wiring.
	DeploymentLogResolver deploymentlogs.LogResolver

	// PerKindHooks injects per-kind Authorize + ListFilter
	// callbacks into the generic resource handler. Downstream integrations
	// thread their RBAC engine through here so reader / publisher /
	// admin gates fire on the OSS-registered Agent / MCPServer / Skill
	// / Prompt / Runtime / Deployment endpoints. Zero-value matches
	// the public OSS default (no per-kind gates).
	PerKindHooks crud.PerKindHooks

	// RegistryValidator overrides the per-package registry
	// validator on the apply path. Nil falls back to
	// registries.Dispatcher, the upstream public-catalogue default.
	// See types.AppOptions.RegistryValidator for the full
	// rationale (private deployments typically swap in a filter that
	// short-circuits OCI).
	RegistryValidator v1alpha1.RegistryValidatorFunc

	// Optional callback for integration-owned route registration.
	ExtraRoutes func(api huma.API, pathPrefix string)

	// Admission optionally owns the final apply write. Nil preserves OSS
	// production writes through resource.ProductionAdmission.
	// TODO(controller): temporary synchronous-handler bridge; remove when
	// reconciler-owned admission/staging exists.
	Admission types.Admission

	// DeleteAdmission optionally owns the final delete. Nil preserves OSS
	// production deletes through resource.ProductionDeleteAdmission.
	// TODO(controller): temporary synchronous-handler bridge; remove when
	// reconciler-owned admission/staging exists.
	DeleteAdmission types.DeleteAdmission

	// ResolverWrapper decorates the shared ResourceRef resolver before
	// resource and apply routes are registered.
	// TODO(controller): temporary bridge for pending staged refs during HTTP apply.
	ResolverWrapper func(v1alpha1.ResolverFunc) v1alpha1.ResolverFunc

	// ExtraResourceRoutes registers adjacent routes with access to the same
	// v1alpha1 stores and hooks used by /v0/apply.
	// TODO(controller): temporary bridge for downstream synchronous approval routes.
	ExtraResourceRoutes func(api huma.API, pathPrefix string, ctx types.ResourceRouteContext)
}

RouteOptions contains the services that drive route registration.

Stores is required; everything else is optional and gates a specific feature area (deployments). RegisterRoutes returns an error if a required field is missing rather than silently no-op'ing — a misconfigured boot fails loud.

type Stores added in v0.4.0

type Stores = map[string]*v1alpha1store.Store

Stores is the per-kind Store map used by the v1alpha1 resource handler, keyed by v1alpha1 Kind name (e.g. "Agent", "MCPServer"). Produced by v1alpha1store.NewStores; downstream builds may extend the map with additional kinds before passing it in.

Jump to

Keyboard shortcuts

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