Documentation
¶
Index ¶
- Constants
- func InstallEdgeMiddleware(router chi.Router, cfg *platform.Config, cookieSecure bool) (mountMetrics func())
- func NewNotifierForTest(pool *pgxpool.Pool) *webhooks.Notifier
- func RegisterAPIRoutes(api huma.API, router chi.Router, d RegisterAPIDeps) *evalqueue.PoolExecutor
- type AllowAll
- type AllowAllPolicy
- type AuditEvent
- type AuditLogger
- type Authorizer
- type Builder
- func (b *Builder) Build() (*Server, error)
- func (b *Builder) Capabilities() *Capabilities
- func (b *Builder) WithAuditLog(l AuditLogger) *Builder
- func (b *Builder) WithAuthorizer(a Authorizer) *Builder
- func (b *Builder) WithEdition(edition string) *Builder
- func (b *Builder) WithIdentityProvider(idp IdentityProvider) *Builder
- func (b *Builder) WithLicense(l *LicenseInfo) *Builder
- func (b *Builder) WithPolicyEnforcer(p PolicyEnforcer) *Builder
- func (b *Builder) WithRoutes(registrars ...RouteRegistrar) *Builder
- func (b *Builder) WithScanRules(s ScanRuleProvider) *Builder
- func (b *Builder) WithVersion(version string) *Builder
- type Capabilities
- func (c *Capabilities) EnableFeature(name string)
- func (c *Capabilities) Register(api huma.API)
- func (c *Capabilities) Response() CapabilitiesResponse
- func (c *Capabilities) SetEdition(edition string)
- func (c *Capabilities) SetLicense(l *LicenseInfo)
- func (c *Capabilities) SetSignIn(m auth.SignInMethods)
- func (c *Capabilities) SetVersion(v string)
- type CapabilitiesResponse
- type Features
- type IdentityProvider
- type LicenseInfo
- type NoopAuditLogger
- type PolicyEnforcer
- type ReadyChecks
- type RegisterAPIDeps
- type RouteRegistrar
- type ScanRuleProvider
- type Server
Constants ¶
const RiverUIPrefix = "/api/admin/river"
RiverUIPrefix is where River UI mounts. The auth middleware covers only /api/, and the route table holds no scope for it, so a service key never reaches it.
Variables ¶
This section is empty.
Functions ¶
func InstallEdgeMiddleware ¶ added in v0.9.0
func InstallEdgeMiddleware(router chi.Router, cfg *platform.Config, cookieSecure bool) (mountMetrics func())
InstallEdgeMiddleware registers every middleware a request passes through before it reaches session handling, authentication, or any route: security headers, request ID, CORS, panic recovery, request logging, and rate limiting (plus Prometheus instrumentation unless METRICS_ENABLED=false).
Order matters here, and it is the reason this lives in its own function rather than inline in Build: the rate limiter and the request logger both need to agree on who a request came from, so anything that establishes the client identity must run before either of them. Exporting it lets tests exercise the real chain — in the real order — without a database.
It returns mountMetrics, which registers the /metrics endpoint. Callers must call it only after adding every middleware of their own: chi panics if Use is called once any route exists on the mux, and route registration order has no effect on which middleware a route runs through.
func NewNotifierForTest ¶ added in v0.16.0
NewNotifierForTest builds a notifier over an insert-only client, so a test can drive a change inside a transaction of its own.
func RegisterAPIRoutes ¶ added in v0.10.0
func RegisterAPIRoutes(api huma.API, router chi.Router, d RegisterAPIDeps) *evalqueue.PoolExecutor
RegisterAPIRoutes registers every /api/* route: health, readiness, capabilities, auth, skills, sync manifest, analytics, import, eval suites, eval queue, and quality. It does not register the embedded SPA catch-all — callers that serve the SPA (only Build) mount that separately, after this returns, per Huma/chi ordering requirements.
It returns the eval queue's PoolExecutor so Build can start the lease reaper against the same queue this registered — constructing a second PoolExecutor there would work against the same table but would be a needless second handle, and would drift from this function if the two ever needed to differ.
Types ¶
type AllowAllPolicy ¶
type AllowAllPolicy struct{}
func (AllowAllPolicy) CheckActivation ¶
func (AllowAllPolicy) CheckActivation(_ context.Context, _, _ string) error
func (AllowAllPolicy) CheckPublish ¶
type AuditEvent ¶
type AuditLogger ¶
type AuditLogger interface {
Log(ctx context.Context, event AuditEvent) error
}
type Authorizer ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder assembles a Server from its constituent parts. The zero value is not useful — use NewBuilder. Callers chain With* methods to opt into enterprise extension points, then call Build to get a runnable Server.
func NewBuilder ¶
NewBuilder creates a Builder with OSS defaults: no extension points, no enterprise features, edition "oss".
func (*Builder) Build ¶
Build assembles all server components from the builder and returns a Server ready to serve. It creates the session manager, storage, auth stores, router, Huma API, all routes, and the embedded SPA mount. It does NOT call ListenAndServe — that's a separate method on Server so callers can inject test transports or configure TLS before starting.
func (*Builder) Capabilities ¶
func (b *Builder) Capabilities() *Capabilities
Capabilities returns the Capabilities value accumulated so far. This is primarily useful for testing — in production you call Build.
func (*Builder) WithAuditLog ¶
func (b *Builder) WithAuditLog(l AuditLogger) *Builder
WithAuditLog attaches an AuditLogger and enables the audit feature flag.
func (*Builder) WithAuthorizer ¶
func (b *Builder) WithAuthorizer(a Authorizer) *Builder
WithAuthorizer attaches an Authorizer (RBAC) and enables the rbac and teams feature flags.
func (*Builder) WithEdition ¶
WithEdition overrides the edition string (e.g. "enterprise") in capability responses.
func (*Builder) WithIdentityProvider ¶
func (b *Builder) WithIdentityProvider(idp IdentityProvider) *Builder
WithIdentityProvider attaches an IdentityProvider (SSO) and enables the sso feature flag.
func (*Builder) WithLicense ¶
func (b *Builder) WithLicense(l *LicenseInfo) *Builder
WithLicense sets the license metadata returned by the capabilities endpoint.
func (*Builder) WithPolicyEnforcer ¶
func (b *Builder) WithPolicyEnforcer(p PolicyEnforcer) *Builder
WithPolicyEnforcer attaches a PolicyEnforcer and enables the governance feature flag.
func (*Builder) WithRoutes ¶
func (b *Builder) WithRoutes(registrars ...RouteRegistrar) *Builder
WithRoutes registers additional route registrars that are called during Build after all core routes are wired. Enterprise plugins use this to inject their own endpoints.
func (*Builder) WithScanRules ¶
func (b *Builder) WithScanRules(s ScanRuleProvider) *Builder
WithScanRules attaches a ScanRuleProvider and enables the custom_scan feature flag.
func (*Builder) WithVersion ¶ added in v0.10.0
WithVersion records the build version reported by the capabilities endpoint, so the dashboard and the server logs agree about which build is running.
type Capabilities ¶
type Capabilities struct {
// contains filtered or unexported fields
}
func NewCapabilities ¶
func NewCapabilities() *Capabilities
func (*Capabilities) EnableFeature ¶
func (c *Capabilities) EnableFeature(name string)
func (*Capabilities) Register ¶
func (c *Capabilities) Register(api huma.API)
func (*Capabilities) Response ¶
func (c *Capabilities) Response() CapabilitiesResponse
func (*Capabilities) SetEdition ¶
func (c *Capabilities) SetEdition(edition string)
func (*Capabilities) SetLicense ¶
func (c *Capabilities) SetLicense(l *LicenseInfo)
func (*Capabilities) SetSignIn ¶ added in v0.17.0
func (c *Capabilities) SetSignIn(m auth.SignInMethods)
SetSignIn records the sign-in methods the SPA may show.
func (*Capabilities) SetVersion ¶ added in v0.10.0
func (c *Capabilities) SetVersion(v string)
SetVersion records the build version reported by /api/capabilities. An empty value is ignored rather than stored: an unstamped build should read "dev", not blank.
type CapabilitiesResponse ¶
type CapabilitiesResponse struct {
Edition string `json:"edition"`
Version string `json:"version"`
Features Features `json:"features"`
License *LicenseInfo `json:"license"`
SignIn auth.SignInMethods `json:"sign_in"`
}
type IdentityProvider ¶
type LicenseInfo ¶
type NoopAuditLogger ¶
type NoopAuditLogger struct{}
func (NoopAuditLogger) Log ¶
func (NoopAuditLogger) Log(_ context.Context, _ AuditEvent) error
type PolicyEnforcer ¶
type ReadyChecks ¶ added in v0.6.0
ReadyChecks holds the per-dependency readiness status. Each field is either "ok" or "unavailable" — real errors are logged server-side and never included in the HTTP response.
type RegisterAPIDeps ¶ added in v0.10.0
type RegisterAPIDeps struct {
Pool *pgxpool.Pool
Config *platform.Config
People *auth.People
UserStore *auth.UserStore
KeyStore *auth.KeyStore
Storage platform.Storage
Caps *Capabilities
// AnalyticsStore is optional; if nil, RegisterAPIRoutes constructs one
// from Pool. Build() passes its own instance so the same store can be
// reused for startup event-retention cleanup instead of constructing a
// second one.
AnalyticsStore *analytics.Store
// JobInserter enqueues webhook deliveries inside a change's transaction.
// Nil only for spec generation, which never runs a handler.
JobInserter webhooks.JobInserter
// RiverUI serves the job inspector. Nil only for spec generation.
RiverUI http.Handler
}
RegisterAPIDeps bundles everything RegisterAPIRoutes needs to wire the API. Every field except Pool, Router, and Caps may be nil (or the pool may be nil): RegisterAPIRoutes is used both by the real server, where every field is a live dependency, and by `skael-server --openapi`, which only needs the route shapes for spec generation and never executes a handler. The stores constructed here (skill.NewStore, evalqueue.NewPool, etc.) hold their pool reference lazily and don't touch it until a handler runs, so a nil pool is safe for registration-only use.
This is the single place both paths register routes from, specifically so they should not drift apart — see cmd/server/main.go's printOpenAPISpec. The guard test (routes_test.go) only checks routes registered inside this function; a new route group must be added here, not via a direct huma.Register call in Build() after RegisterAPIRoutes returns, or the guard cannot see it and the spec can silently drift again.
type RouteRegistrar ¶
RouteRegistrar is a function that registers additional routes onto the Huma API and Chi router. Enterprise plugins use this to add their own endpoints.
type ScanRuleProvider ¶
type Server ¶
type Server struct {
// Handler is the fully assembled Chi router, ready to be passed to
// http.Server or used in tests with httptest.NewServer.
Handler http.Handler
// contains filtered or unexported fields
}
Server wraps the assembled HTTP handler and configuration needed to start listening. Build() produces a Server; ListenAndServe() runs it.
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server and blocks until a SIGINT or SIGTERM is received, then performs a graceful shutdown with a 10-second timeout.