Documentation
¶
Index ¶
- func AddHealthRoutes(mux *http.ServeMux)
- func AddVersionRoutes(mux *http.ServeMux, version, nodeInstanceID, tenancy string)
- func Handler(mux *http.ServeMux, config *Config) http.Handler
- func IsLoopbackAddress(addr string) bool
- func LoadConfig[T any](cfg *T) error
- func New(ctx context.Context, mux *http.ServeMux, nodeInstanceID, tenancy string, ...) (func() error, error)
- func ProtectMutatingAPI(token string, next http.Handler) http.Handler
- func ValidateLocalServeSecurity(addr, token string) error
- type Config
- type Dependencies
- type HealthResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHealthRoutes ¶
AddHealthRoutes registers GET /health for liveness checks.
func AddVersionRoutes ¶
AddVersionRoutes registers GET /version.
func Handler ¶ added in v0.32.8
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 LoadConfig ¶
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.
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"`
}