Documentation
¶
Index ¶
- Variables
- func NewExtension(opts ...ConfigOption) forge.Extension
- type BridgeAware
- type Config
- type ConfigOption
- func WithBasePath(path string) ConfigOption
- func WithBridge(enabled bool) ConfigOption
- func WithCSP(enabled bool) ConfigOption
- func WithCSRF(enabled bool) ConfigOption
- func WithCacheMaxSize(size int) ConfigOption
- func WithCacheTTL(ttl time.Duration) ConfigOption
- func WithConfig(config Config) ConfigOption
- func WithCustomCSS(css string) ConfigOption
- func WithDefaultAccess(access string) ConfigOption
- func WithDiscovery(enabled bool) ConfigOption
- func WithDiscoveryPollInterval(interval time.Duration) ConfigOption
- func WithDiscoveryTag(tag string) ConfigOption
- func WithEnableAuth(enabled bool) ConfigOption
- func WithExport(enabled bool) ConfigOption
- func WithExportFormats(formats []string) ConfigOption
- func WithHistoryDuration(duration time.Duration) ConfigOption
- func WithLoginPath(path string) ConfigOption
- func WithLogoutPath(path string) ConfigOption
- func WithMaxDataPoints(maxPoints int) ConfigOption
- func WithProxyTimeout(timeout time.Duration) ConfigOption
- func WithRealtime(enabled bool) ConfigOption
- func WithRefreshInterval(interval time.Duration) ConfigOption
- func WithRequireConfig(required bool) ConfigOption
- func WithSSEKeepAlive(interval time.Duration) ConfigOption
- func WithSearch(enabled bool) ConfigOption
- func WithSettings(enabled bool) ConfigOption
- func WithTheme(theme string) ConfigOption
- func WithTitle(title string) ConfigOption
- type CoreContributor
- func (c *CoreContributor) Manifest() *contributor.Manifest
- func (c *CoreContributor) RenderPage(ctx context.Context, route string, params contributor.Params) (templ.Component, error)
- func (c *CoreContributor) RenderSettings(_ context.Context, _ string) (templ.Component, error)
- func (c *CoreContributor) RenderWidget(ctx context.Context, widgetID string) (templ.Component, error)
- type DashboardAware
- type DashboardBridge
- type EmptyParams
- type Extension
- func (e *Extension) AuthChecker() dashauth.AuthChecker
- func (e *Extension) AuthPageProvider() dashauth.AuthPageProvider
- func (e *Extension) CSRFManager() *security.CSRFManager
- func (e *Extension) Collector() *collector.DataCollector
- func (e *Extension) DashboardBridge() *DashboardBridge
- func (e *Extension) Dependencies() []string
- func (e *Extension) ForgeUIApp() *forgeui.App
- func (e *Extension) FragmentProxy() *proxy.FragmentProxy
- func (e *Extension) Health(ctx context.Context) error
- func (e *Extension) History() *collector.DataHistory
- func (e *Extension) RecoveryManager() *recovery.Manager
- func (e *Extension) Register(app forge.App) error
- func (e *Extension) RegisterBridgeFunction(name string, handler any, opts ...bridge.FunctionOption) error
- func (e *Extension) RegisterContributor(c contributor.LocalContributor) error
- func (e *Extension) Registry() *contributor.ContributorRegistry
- func (e *Extension) SSEBroker() *sse.Broker
- func (e *Extension) Sanitizer() *security.Sanitizer
- func (e *Extension) Searcher() *search.FederatedSearch
- func (e *Extension) SetAuthChecker(checker dashauth.AuthChecker)
- func (e *Extension) SetAuthPageProvider(provider dashauth.AuthPageProvider)
- func (e *Extension) SetDiscoveryService(svc dashboarddiscovery.DiscoveryService)
- func (e *Extension) SettingsAggregator() *settings.Aggregator
- func (e *Extension) Start(ctx context.Context) error
- func (e *Extension) Stop(ctx context.Context) error
- func (e *Extension) ThemeManager() *dashtheme.Manager
- type ServiceNameParams
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPageNotFound is returned when a requested page does not exist. ErrPageNotFound = errors.New("dashboard: page not found") // ErrWidgetNotFound is returned when a requested widget does not exist. ErrWidgetNotFound = errors.New("dashboard: widget not found") // ErrSettingNotFound is returned when a requested setting does not exist. ErrSettingNotFound = errors.New("dashboard: setting not found") // ErrContributorExists is returned when a contributor with the same name is already registered. ErrContributorExists = errors.New("dashboard: contributor already registered") // ErrContributorNotFound is returned when a contributor is not found in the registry. ErrContributorNotFound = errors.New("dashboard: contributor not found") // ErrRemoteUnreachable is returned when a remote contributor cannot be reached. ErrRemoteUnreachable = errors.New("dashboard: remote contributor unreachable") // ErrManifestFetch is returned when fetching a remote manifest fails. ErrManifestFetch = errors.New("dashboard: failed to fetch remote manifest") // ErrDiscoveryTimeout is returned when service discovery times out. ErrDiscoveryTimeout = errors.New("dashboard: service discovery timed out") // ErrRecoveryFailed is returned when UI recovery fails. ErrRecoveryFailed = errors.New("dashboard: UI recovery failed") // ErrCollectorNotInitialized is returned when the data collector is not initialized. ErrCollectorNotInitialized = errors.New("dashboard: collector not initialized") )
Functions ¶
func NewExtension ¶
func NewExtension(opts ...ConfigOption) forge.Extension
NewExtension creates a new dashboard extension.
Types ¶
type BridgeAware ¶ added in v0.10.0
BridgeAware is an optional interface that Forge extensions can implement to register custom Go↔JS bridge functions with the dashboard. Extensions implementing this interface have RegisterDashboardBridge called during dashboard Start() after the bridge is initialized.
Example implementation:
func (a *AuthExtension) RegisterDashboardBridge(b *bridge.Bridge) error {
return b.Register("auth.getStats", a.handleGetStats,
bridge.WithDescription("Get auth statistics"),
)
}
type Config ¶
type Config struct {
// Server settings
BasePath string `json:"base_path" yaml:"base_path"`
Title string `json:"title" yaml:"title"`
// Features
EnableRealtime bool `json:"enable_realtime" yaml:"enable_realtime"` // SSE real-time updates
EnableExport bool `json:"enable_export" yaml:"enable_export"`
EnableSearch bool `json:"enable_search" yaml:"enable_search"`
EnableSettings bool `json:"enable_settings" yaml:"enable_settings"`
EnableDiscovery bool `json:"enable_discovery" yaml:"enable_discovery"` // auto-discover remote contributors
EnableBridge bool `json:"enable_bridge" yaml:"enable_bridge"` // Go↔JS bridge function system
// Data collection
RefreshInterval time.Duration `json:"refresh_interval" yaml:"refresh_interval"`
HistoryDuration time.Duration `json:"history_duration" yaml:"history_duration"`
MaxDataPoints int `json:"max_data_points" yaml:"max_data_points"`
// Proxy/Remote
ProxyTimeout time.Duration `json:"proxy_timeout" yaml:"proxy_timeout"`
CacheMaxSize int `json:"cache_max_size" yaml:"cache_max_size"`
CacheTTL time.Duration `json:"cache_ttl" yaml:"cache_ttl"`
// SSE
SSEKeepAlive time.Duration `json:"sse_keep_alive" yaml:"sse_keep_alive"`
// Security
EnableCSP bool `json:"enable_csp" yaml:"enable_csp"`
EnableCSRF bool `json:"enable_csrf" yaml:"enable_csrf"`
// Authentication
EnableAuth bool `json:"enable_auth" yaml:"enable_auth"` // enable auth support
LoginPath string `json:"login_path" yaml:"login_path"` // relative auth login path (e.g. "/auth/login")
LogoutPath string `json:"logout_path" yaml:"logout_path"` // relative auth logout path (e.g. "/auth/logout")
DefaultAccess string `json:"default_access" yaml:"default_access"` // "public", "protected", "partial"
// Theming
Theme string `json:"theme" yaml:"theme"` // light, dark, auto
CustomCSS string `json:"custom_css" yaml:"custom_css"`
// Discovery
DiscoveryTag string `json:"discovery_tag" yaml:"discovery_tag"`
DiscoveryPollInterval time.Duration `json:"discovery_poll_interval" yaml:"discovery_poll_interval"`
// Export
ExportFormats []string `json:"export_formats" yaml:"export_formats"`
// Internal
RequireConfig bool `json:"-" yaml:"-"`
}
Config contains dashboard extension configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default dashboard configuration.
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption is a functional option for Config.
func WithBasePath ¶
func WithBasePath(path string) ConfigOption
WithBasePath sets the base URL path for the dashboard.
func WithBridge ¶ added in v0.9.12
func WithBridge(enabled bool) ConfigOption
WithBridge enables or disables the Go↔JS bridge function system.
func WithCSP ¶ added in v0.9.12
func WithCSP(enabled bool) ConfigOption
WithCSP enables or disables Content-Security-Policy headers.
func WithCSRF ¶ added in v0.9.12
func WithCSRF(enabled bool) ConfigOption
WithCSRF enables or disables CSRF token protection.
func WithCacheMaxSize ¶ added in v0.9.12
func WithCacheMaxSize(size int) ConfigOption
WithCacheMaxSize sets the maximum number of cached fragments.
func WithCacheTTL ¶ added in v0.9.12
func WithCacheTTL(ttl time.Duration) ConfigOption
WithCacheTTL sets the time-to-live for cached fragments.
func WithCustomCSS ¶ added in v0.9.12
func WithCustomCSS(css string) ConfigOption
WithCustomCSS sets custom CSS to inject into the dashboard.
func WithDefaultAccess ¶ added in v0.10.0
func WithDefaultAccess(access string) ConfigOption
WithDefaultAccess sets the default access level for pages ("public", "protected", "partial").
func WithDiscovery ¶ added in v0.9.12
func WithDiscovery(enabled bool) ConfigOption
WithDiscovery enables or disables automatic service discovery of remote contributors.
func WithDiscoveryPollInterval ¶ added in v0.9.12
func WithDiscoveryPollInterval(interval time.Duration) ConfigOption
WithDiscoveryPollInterval sets how often to poll for new contributors via discovery.
func WithDiscoveryTag ¶ added in v0.9.12
func WithDiscoveryTag(tag string) ConfigOption
WithDiscoveryTag sets the service discovery tag to filter dashboard contributors.
func WithEnableAuth ¶ added in v0.10.0
func WithEnableAuth(enabled bool) ConfigOption
WithEnableAuth enables or disables authentication support.
func WithExport ¶
func WithExport(enabled bool) ConfigOption
WithExport enables or disables export functionality.
func WithExportFormats ¶ added in v0.9.12
func WithExportFormats(formats []string) ConfigOption
WithExportFormats sets the supported export formats.
func WithHistoryDuration ¶
func WithHistoryDuration(duration time.Duration) ConfigOption
WithHistoryDuration sets the data retention duration.
func WithLoginPath ¶ added in v0.10.0
func WithLoginPath(path string) ConfigOption
WithLoginPath sets the relative login page path (e.g. "/auth/login").
func WithLogoutPath ¶ added in v0.10.0
func WithLogoutPath(path string) ConfigOption
WithLogoutPath sets the relative logout page path (e.g. "/auth/logout").
func WithMaxDataPoints ¶
func WithMaxDataPoints(maxPoints int) ConfigOption
WithMaxDataPoints sets the maximum number of data points to retain.
func WithProxyTimeout ¶ added in v0.9.12
func WithProxyTimeout(timeout time.Duration) ConfigOption
WithProxyTimeout sets the timeout for proxying requests to remote contributors.
func WithRealtime ¶
func WithRealtime(enabled bool) ConfigOption
WithRealtime enables or disables real-time SSE updates.
func WithRefreshInterval ¶
func WithRefreshInterval(interval time.Duration) ConfigOption
WithRefreshInterval sets the data collection refresh interval.
func WithRequireConfig ¶
func WithRequireConfig(required bool) ConfigOption
WithRequireConfig requires config from ConfigManager.
func WithSSEKeepAlive ¶ added in v0.9.12
func WithSSEKeepAlive(interval time.Duration) ConfigOption
WithSSEKeepAlive sets the SSE keep-alive interval.
func WithSearch ¶ added in v0.9.12
func WithSearch(enabled bool) ConfigOption
WithSearch enables or disables global search.
func WithSettings ¶ added in v0.9.12
func WithSettings(enabled bool) ConfigOption
WithSettings enables or disables aggregated settings pages.
func WithTheme ¶
func WithTheme(theme string) ConfigOption
WithTheme sets the UI theme (light, dark, auto).
type CoreContributor ¶ added in v0.9.12
type CoreContributor struct {
// contains filtered or unexported fields
}
CoreContributor is the built-in contributor providing Overview, Health, Metrics, and Services pages. It implements contributor.LocalContributor.
func NewCoreContributor ¶ added in v0.9.12
func NewCoreContributor(c *collector.DataCollector, h *collector.DataHistory) *CoreContributor
NewCoreContributor creates a new CoreContributor.
func (*CoreContributor) Manifest ¶ added in v0.9.12
func (c *CoreContributor) Manifest() *contributor.Manifest
Manifest returns the core contributor's manifest.
func (*CoreContributor) RenderPage ¶ added in v0.9.12
func (c *CoreContributor) RenderPage(ctx context.Context, route string, params contributor.Params) (templ.Component, error)
RenderPage renders a page for the given route.
func (*CoreContributor) RenderSettings ¶ added in v0.9.12
RenderSettings renders a settings panel. Core has no settings.
func (*CoreContributor) RenderWidget ¶ added in v0.9.12
func (c *CoreContributor) RenderWidget(ctx context.Context, widgetID string) (templ.Component, error)
RenderWidget renders a specific widget by ID.
type DashboardAware ¶ added in v0.10.0
type DashboardAware interface {
DashboardContributor() contributor.LocalContributor
}
DashboardAware is an optional interface that Forge extensions can implement to signal that they bundle a dashboard contributor. The dashboard extension auto-discovers extensions implementing this interface during Start() and registers their contributors automatically — no manual registration needed.
The returned contributor can be an EmbeddedContributor (static build), SSRContributor (Node.js sidecar), or any other LocalContributor.
Example implementation in an extension:
func (a *AuthExtension) DashboardContributor() contributor.LocalContributor {
return newDashboardContributor() // generated by forge contributor build
}
type DashboardBridge ¶ added in v0.9.12
type DashboardBridge struct {
// contains filtered or unexported fields
}
DashboardBridge wraps a forgeui bridge.Bridge to provide Go↔JS communication for the dashboard. Bridge functions can be called from the browser via Alpine.js magic helpers ($go, $goBatch, $goStream) or the ForgeBridge JS client.
func NewDashboardBridge ¶ added in v0.9.12
func NewDashboardBridge(c *collector.DataCollector, h *collector.DataHistory) *DashboardBridge
NewDashboardBridge creates a new bridge with built-in dashboard functions registered.
func NewDashboardBridgeWithBridge ¶ added in v0.9.12
func NewDashboardBridgeWithBridge(b *bridge.Bridge, c *collector.DataCollector, h *collector.DataHistory) *DashboardBridge
NewDashboardBridgeWithBridge wraps an existing forgeui bridge instance with dashboard functions. Use this when the bridge is created by forgeui.App (via forgeui.WithBridge()).
func (*DashboardBridge) Bridge ¶ added in v0.9.12
func (db *DashboardBridge) Bridge() *bridge.Bridge
Bridge returns the underlying forgeui bridge instance.
func (*DashboardBridge) Register ¶ added in v0.9.12
func (db *DashboardBridge) Register(name string, handler any, opts ...bridge.FunctionOption) error
Register registers a custom bridge function. Extensions can use this to expose Go functions callable from the dashboard UI.
type EmptyParams ¶ added in v0.9.12
type EmptyParams struct{}
EmptyParams is used for functions that take no input.
type Extension ¶
type Extension struct {
*forge.BaseExtension
// contains filtered or unexported fields
}
Extension implements the extensible dashboard micro-frontend shell. Contributors (local or remote) register pages, widgets, and settings that are merged into a unified admin dashboard.
func (*Extension) AuthChecker ¶ added in v0.10.0
func (e *Extension) AuthChecker() dashauth.AuthChecker
AuthChecker returns the configured authentication checker. Returns nil if none is set.
func (*Extension) AuthPageProvider ¶ added in v0.10.0
func (e *Extension) AuthPageProvider() dashauth.AuthPageProvider
AuthPageProvider returns the configured auth page provider. Returns nil if none is set.
func (*Extension) CSRFManager ¶ added in v0.9.12
func (e *Extension) CSRFManager() *security.CSRFManager
CSRFManager returns the CSRF token manager. Returns nil if CSRF is disabled.
func (*Extension) Collector ¶ added in v0.8.0
func (e *Extension) Collector() *collector.DataCollector
Collector returns the data collector instance.
func (*Extension) DashboardBridge ¶ added in v0.9.12
func (e *Extension) DashboardBridge() *DashboardBridge
DashboardBridge returns the dashboard bridge instance for registering custom functions. Returns nil if the bridge is not enabled.
func (*Extension) Dependencies ¶
Dependencies returns extension dependencies.
func (*Extension) ForgeUIApp ¶ added in v0.9.12
ForgeUIApp returns the forgeui application instance.
func (*Extension) FragmentProxy ¶ added in v0.9.12
func (e *Extension) FragmentProxy() *proxy.FragmentProxy
FragmentProxy returns the fragment proxy for remote contributors.
func (*Extension) History ¶ added in v0.8.0
func (e *Extension) History() *collector.DataHistory
History returns the data history instance.
func (*Extension) RecoveryManager ¶ added in v0.9.12
RecoveryManager returns the recovery manager for remote contributors.
func (*Extension) RegisterBridgeFunction ¶ added in v0.9.12
func (e *Extension) RegisterBridgeFunction(name string, handler any, opts ...bridge.FunctionOption) error
RegisterBridgeFunction registers a custom bridge function callable from the dashboard UI. This is a convenience method — callers can also use DashboardBridge().Register() directly. Returns an error if the bridge is not enabled.
func (*Extension) RegisterContributor ¶ added in v0.9.12
func (e *Extension) RegisterContributor(c contributor.LocalContributor) error
RegisterContributor registers a local contributor with the dashboard. This is the primary API for extensions to contribute UI to the dashboard.
func (*Extension) Registry ¶ added in v0.9.12
func (e *Extension) Registry() *contributor.ContributorRegistry
Registry returns the contributor registry.
func (*Extension) SSEBroker ¶ added in v0.9.12
SSEBroker returns the SSE event broker. Returns nil if real-time is disabled.
func (*Extension) Sanitizer ¶ added in v0.9.12
Sanitizer returns the HTML sanitizer for remote fragments.
func (*Extension) Searcher ¶ added in v0.9.12
func (e *Extension) Searcher() *search.FederatedSearch
Searcher returns the federated search engine. Returns nil if search is disabled.
func (*Extension) SetAuthChecker ¶ added in v0.10.0
func (e *Extension) SetAuthChecker(checker dashauth.AuthChecker)
SetAuthChecker configures the authentication checker used to validate requests. Call this after Register() and before Start(). When auth is enabled, the checker is invoked on every request to populate the user context.
Example using the adapter for the forge auth extension:
checker := dashauth.NewAuthExtensionChecker(authRegistry, "oidc") dashExt.SetAuthChecker(checker)
func (*Extension) SetAuthPageProvider ¶ added in v0.10.0
func (e *Extension) SetAuthPageProvider(provider dashauth.AuthPageProvider)
SetAuthPageProvider configures the provider that contributes authentication pages (login, logout, register, etc.) to the dashboard. Call this after Register() and before Start().
func (*Extension) SetDiscoveryService ¶ added in v0.9.12
func (e *Extension) SetDiscoveryService(svc dashboarddiscovery.DiscoveryService)
SetDiscoveryService configures the discovery service used to auto-discover remote dashboard contributors. Call this before Start() if discovery is enabled.
The discovery service must implement dashboarddiscovery.DiscoveryService (ListServices + DiscoverWithTags). The forge extensions/discovery.Service type satisfies this interface.
Example:
dashExt.SetDiscoveryService(discoveryExtension.Service())
func (*Extension) SettingsAggregator ¶ added in v0.9.12
func (e *Extension) SettingsAggregator() *settings.Aggregator
SettingsAggregator returns the settings aggregator. Returns nil if settings is disabled.
func (*Extension) ThemeManager ¶ added in v0.9.12
ThemeManager returns the theme manager.
type ServiceNameParams ¶ added in v0.9.12
type ServiceNameParams struct {
Name string `json:"name"`
}
ServiceNameParams is used for functions that take a service name.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dashauth provides authentication and authorization abstractions for the dashboard extension.
|
Package dashauth provides authentication and authorization abstractions for the dashboard extension. |
|
codegen
Package codegen generates Go source files from forge.contributor.yaml configuration.
|
Package codegen generates Go source files from forge.contributor.yaml configuration. |
|
config
Package config defines the schema for forge.contributor.yaml configuration files that declare dashboard contributor metadata, navigation, widgets, settings, and build configuration.
|
Package config defines the schema for forge.contributor.yaml configuration files that declare dashboard contributor metadata, navigation, widgets, settings, and build configuration. |
|
examples
|
|
|
basic
command
Package main demonstrates a basic dashboard setup with built-in pages only.
|
Package main demonstrates a basic dashboard setup with built-in pages only. |
|
contributor
command
Package main demonstrates how to create a custom LocalContributor that adds pages, widgets, and settings to the dashboard.
|
Package main demonstrates how to create a custom LocalContributor that adds pages, widgets, and settings to the dashboard. |
|
remote
command
Package main demonstrates how to register a remote contributor with the dashboard extension.
|
Package main demonstrates how to register a remote contributor with the dashboard extension. |
|
templ: version: v0.3.977
|
templ: version: v0.3.977 |
|
Package theme provides a dashboard-specific wrapper around the forgeui theme system.
|
Package theme provides a dashboard-specific wrapper around the forgeui theme system. |
|
templ: version: v0.3.977
|
templ: version: v0.3.977 |
|
pages
templ: version: v0.3.977
|
templ: version: v0.3.977 |
|
shell
templ: version: v0.3.977
|
templ: version: v0.3.977 |