server

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowAll

type AllowAll struct{}

func (AllowAll) Authorize

func (AllowAll) Authorize(_ context.Context, _ *auth.User, _, _ string) error

type AllowAllPolicy

type AllowAllPolicy struct{}

func (AllowAllPolicy) CheckActivation

func (AllowAllPolicy) CheckActivation(_ context.Context, _, _ string) error

func (AllowAllPolicy) CheckPublish

func (AllowAllPolicy) CheckPublish(_ context.Context, _ *skill.Skill) error

type AuditEvent

type AuditEvent struct {
	UserID   string
	Action   string
	Resource string
	Detail   string
}

type AuditLogger

type AuditLogger interface {
	Log(ctx context.Context, event AuditEvent) error
}

type Authorizer

type Authorizer interface {
	Authorize(ctx context.Context, user *auth.User, action, resource string) error
}

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

func NewBuilder(pool *pgxpool.Pool, config *platform.Config) *Builder

NewBuilder creates a Builder with OSS defaults: no extension points, no enterprise features, edition "oss".

func (*Builder) Build

func (b *Builder) Build() (*Server, error)

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

func (b *Builder) WithEdition(edition string) *Builder

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.

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)

type CapabilitiesResponse

type CapabilitiesResponse struct {
	Edition  string       `json:"edition"`
	Features Features     `json:"features"`
	License  *LicenseInfo `json:"license"`
}

type Features

type Features struct {
	Teams             bool `json:"teams"`
	RBAC              bool `json:"rbac"`
	SSO               bool `json:"sso"`
	Audit             bool `json:"audit"`
	Governance        bool `json:"governance"`
	CustomScan        bool `json:"custom_scan"`
	AdvancedAnalytics bool `json:"advanced_analytics"`
}

type IdentityProvider

type IdentityProvider interface {
	Authenticate(ctx context.Context, token string) (*auth.User, error)
	MetadataURL() string
}

type LicenseInfo

type LicenseInfo struct {
	Org     string `json:"org"`
	Seats   int    `json:"seats"`
	Expires string `json:"expires"`
}

type NoopAuditLogger

type NoopAuditLogger struct{}

func (NoopAuditLogger) Log

type PolicyEnforcer

type PolicyEnforcer interface {
	CheckPublish(ctx context.Context, sk *skill.Skill) error
	CheckActivation(ctx context.Context, skillName, agent string) error
}

type ReadyChecks added in v0.6.0

type ReadyChecks struct {
	Database string `json:"database"`
	Storage  string `json:"storage"`
}

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 RouteRegistrar

type RouteRegistrar func(api huma.API, router chi.Router, pool *pgxpool.Pool)

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 ScanRuleProvider interface {
	ExtraRules(ctx context.Context) ([]scan.Rule, error)
}

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

func (s *Server) ListenAndServe() error

ListenAndServe starts the HTTP server and blocks until a SIGINT or SIGTERM is received, then performs a graceful shutdown with a 10-second timeout.

Jump to

Keyboard shortcuts

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