server

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package server exposes the two HTTP endpoints a non-dashboard service needs to advertise itself as a contract contributor that other dashboards can discover + dispatch into.

The dashboard extension already serves /api/dashboard/v1 for its own React shell. A service that doesn't host the dashboard — but wants to contribute intents into one — uses this helper to mount the equivalent surface at /_forge/contract/{manifest,dispatch}. Slice (m) introduced it so multiple microservices can feed a single dashboard, mirroring the legacy templ-based dashboard's remote contributor model.

Index

Constants

View Source
const DefaultPrefix = "/_forge/contract"

DefaultPrefix is the path the dashboard's RemoteContractContributor client expects to find a peer's contract endpoints under.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option configures a Server.

func WithPrefix

func WithPrefix(p string) Option

WithPrefix overrides DefaultPrefix. Useful when the service mounts the contract endpoints under a custom path (proxy compatibility, etc.).

type Server

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

Server bundles the manifest endpoint and the dispatch endpoint into a single http.Handler. Mount it on any net/http mux (or forge.Router via the wrapper helper below). The dispatch endpoint reuses the contract's existing transport.NewHandler so request semantics — envelope parsing, CSRF, idempotency, kind/capability matching, warden checks, audit — stay identical between a dashboard's own /api/dashboard/v1 and a remote service's /_forge/contract/dispatch.

func New

New returns a Server configured to serve the registry + dispatcher passed in. The supplied audit emitter is plumbed through to the dispatch handler; pass contract.NoopAuditEmitter{} when not needed.

func (*Server) DispatchPath

func (s *Server) DispatchPath() string

DispatchPath returns the absolute path to the dispatch endpoint.

func (*Server) HandleDispatch

func (s *Server) HandleDispatch(w http.ResponseWriter, r *http.Request)

HandleDispatch exposes the dispatch handler for the same reason.

func (*Server) HandleManifest

func (s *Server) HandleManifest(w http.ResponseWriter, r *http.Request)

HandleManifest is exported so callers wiring the manifest endpoint onto a custom router (without going through ServeHTTP) can mount it directly.

func (*Server) ManifestPath

func (s *Server) ManifestPath() string

ManifestPath returns the absolute path to the manifest endpoint.

func (*Server) Prefix

func (s *Server) Prefix() string

Prefix returns the configured URL prefix (DefaultPrefix unless overridden).

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes inbound requests to the manifest or dispatch handler based on the suffix beneath Prefix(). 404 for anything else.

Jump to

Keyboard shortcuts

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