serverapi

package
v0.32.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHealthRoutes

func AddHealthRoutes(mux *http.ServeMux)

AddHealthRoutes registers GET /health for liveness checks.

func AddVersionRoutes

func AddVersionRoutes(mux *http.ServeMux, version, nodeInstanceID, tenancy string)

AddVersionRoutes registers GET /version.

func Handler added in v0.32.8

func Handler(mux *http.ServeMux, config *Config) http.Handler

Handler wraps a mux with the standard middleware chain: CORS, request ID, tracing, and (when a token is configured) mutating-method protection.

func IsLoopbackAddress

func IsLoopbackAddress(addr string) bool

func LoadConfig

func LoadConfig[T any](cfg *T) error

LoadConfig populates cfg from environment variables (lowercased keys mapped to json tags).

func New

func New(ctx context.Context, mux *http.ServeMux, nodeInstanceID, tenancy string, config *Config, deps ...Dependencies) (func() error, error)

New registers the spine routes (not-found shape, health, version) on mux and, when deps are supplied, the product API routes. Returns a cleanup function.

func ProtectMutatingAPI

func ProtectMutatingAPI(token string, next http.Handler) http.Handler

func ValidateLocalServeSecurity

func ValidateLocalServeSecurity(addr, token string) error

Types

type Config

type Config struct {
	Addr              string `json:"addr"`
	Port              string `json:"port"`
	Token             string `json:"token"`
	UIBaseURL         string `json:"ui_base_url"`
	AllowedAPIOrigins string `json:"allowed_api_origins"`
	ProxyOrigin       string `json:"proxy_origin"`
	BeamDevProxyURL   string `json:"beam_dev_proxy_url"`
}

Config holds the HTTP serving configuration for `contenox serve`.

type Dependencies

type Dependencies struct {
	DB                   libdb.DBManager
	PubSub               libbus.Messenger
	State                *runtimestate.State
	ToolsProviderService toolsproviderservice.Service
	Auth                 middleware.AuthZReader
	Agent                agentservice.Agent
	ChatManager          *chatservice.Manager
	Chains               taskchainservice.Service
	HITLService          hitlservice.Service
	WorkspaceID          string
	ProjectRoot          string
	ContenoxDir          string
	DefaultChainRef      string
	DefaultModel         string
	DefaultProvider      string
	AltDefaultModel      string
	AltDefaultProvider   string
	DefaultMaxTokens     string
	DefaultThink         string
}

Dependencies are the services the product routes are mounted on. All fields are optional: a route group is only registered when its dependencies are present, so a bare runtime still serves /health and /version.

type HealthResponse

type HealthResponse struct {
	Status string `json:"status"`
}

Jump to

Keyboard shortcuts

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