boot

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 7 Imported by: 0

README

admin/internal/boot

Boot orchestration for the admin runtime.

Purpose

  • Provide an ordered boot pipeline (steps) that mounts routes and wires feature services.
  • Keep admin.Admin thin by pushing boot concerns into focused, testable step functions.

Key Files

  • run.go: Runs steps with a BootCtx.
  • default_steps.go: Default step ordering.
  • types.go: Core BootCtx contract plus binding interfaces (panels, dashboard, etc).
  • step_*.go: Feature-specific boot steps (routes, widgets, jobs, etc).
  • route_helpers.go: Route spec helpers and shared parsing.

Dependencies

  • Leaf package: should not import other admin/internal/* feature packages.
  • Depends on router abstractions (go-router) and the BootCtx interfaces only.

Where To Change X

  • Add/modify default startup sequence: default_steps.go.
  • Mount a new API route group: create/update a step_<feature>.go.
  • Adjust how route paths are built: route_helpers.go.

Documentation

Index

Constants

View Source
const (
	FeatureDashboard     = "dashboard"
	FeatureSearch        = "search"
	FeatureExport        = "export"
	FeatureBulk          = "bulk"
	FeatureMedia         = "media"
	FeatureNotifications = "notifications"
	FeatureJobs          = "jobs"
	FeatureSettings      = "settings"
	FeatureCMS           = "cms"
)

Variables

This section is empty.

Functions

func ActivityRouteStep

func ActivityRouteStep(ctx BootCtx) error

ActivityRouteStep registers activity routes.

func ActivityWidgetStep

func ActivityWidgetStep(ctx BootCtx) error

ActivityWidgetStep registers the activity dashboard provider.

func BulkStep

func BulkStep(ctx BootCtx) error

BulkStep registers bulk routes.

func DashboardProvidersStep

func DashboardProvidersStep(ctx BootCtx) error

DashboardProvidersStep registers built-in dashboard providers.

func DashboardStep

func DashboardStep(ctx BootCtx) error

DashboardStep registers dashboard routes.

func ExportRegistrarStep

func ExportRegistrarStep(ctx BootCtx) error

ExportRegistrarStep registers export routes provided by the host registrar.

func FeatureOverridesRouteStep added in v0.20.0

func FeatureOverridesRouteStep(ctx BootCtx) error

FeatureOverridesRouteStep registers runtime feature override routes.

func HealthStep

func HealthStep(ctx BootCtx) error

HealthStep registers the health route.

func JobsStep

func JobsStep(ctx BootCtx) error

JobsStep registers job routes.

func MediaStep

func MediaStep(ctx BootCtx) error

MediaStep registers media routes.

func NavigationStep(ctx BootCtx) error

NavigationStep registers navigation routes.

func NotificationsRouteStep

func NotificationsRouteStep(ctx BootCtx) error

NotificationsRouteStep registers notifications routes.

func NotificationsWidgetStep

func NotificationsWidgetStep(ctx BootCtx) error

NotificationsWidgetStep registers the notifications dashboard provider.

func PanelStep

func PanelStep(ctx BootCtx) error

PanelStep registers CRUD/action routes for panels.

func PrepareStep

func PrepareStep(ctx BootCtx) error

PrepareStep runs any host-provided pre-route initialization.

func Run

func Run(ctx BootCtx, steps ...Step) error

Run executes steps sequentially until one fails.

func SearchStep

func SearchStep(ctx BootCtx) error

SearchStep registers search routes.

func SettingsRouteStep

func SettingsRouteStep(ctx BootCtx) error

SettingsRouteStep registers settings routes.

func SettingsWidgetStep

func SettingsWidgetStep(ctx BootCtx) error

SettingsWidgetStep registers dashboard providers tied to settings.

func WidgetAreasStep

func WidgetAreasStep(ctx BootCtx) error

WidgetAreasStep registers default dashboard widget areas.

func WidgetDefinitionsStep

func WidgetDefinitionsStep(ctx BootCtx) error

WidgetDefinitionsStep registers default widget definitions.

Types

type ActivityBinding

type ActivityBinding interface {
	List(router.Context) (map[string]any, error)
}

ActivityBinding exposes activity operations.

type BootCtx

type BootCtx interface {
	Router() Router
	AuthWrapper() HandlerWrapper
	BasePath() string
	URLs() urlkit.Resolver
	DefaultLocale() string
	NavMenuCode() string
	Gates() FeatureGates
	Responder() Responder
	ParseBody(router.Context) (map[string]any, error)

	Panels() []PanelBinding
	BootDashboard() DashboardBinding
	BootNavigation() NavigationBinding
	BootSearch() SearchBinding
	ExportRegistrar() ExportRegistrar
	BootBulk() BulkBinding
	BootMedia() MediaBinding
	BootNotifications() NotificationsBinding
	BootActivity() ActivityBinding
	BootJobs() JobsBinding
	BootSettings() SettingsBinding
	BootFeatureOverrides() FeatureOverridesBinding

	SettingsWidget() error
	ActivityWidget() error
	NotificationsWidget() error
	RegisterWidgetAreas() error
	RegisterWidgetDefinitions() error
	RegisterDashboardProviders() error
}

BootCtx exposes the surface needed by boot steps.

type BulkBinding

type BulkBinding interface {
	List(router.Context) (map[string]any, error)
	Start(router.Context, map[string]any) (map[string]any, error)
	Rollback(router.Context, string, map[string]any) (map[string]any, error)
}

BulkBinding exposes bulk operations.

type DashboardBinding

type DashboardBinding interface {
	Enabled() bool
	HasRenderer() bool
	RenderHTML(router.Context, string) (string, error)
	Widgets(router.Context, string) (map[string]any, error)
	Preferences(router.Context, string) (map[string]any, error)
	SavePreferences(router.Context, map[string]any) (map[string]any, error)
}

DashboardBinding exposes dashboard handlers.

type ExportRegistrar

type ExportRegistrar interface {
	Register(Router, ExportRouteOptions) error
}

ExportRegistrar registers export HTTP endpoints on the router.

type ExportRouteOptions

type ExportRouteOptions struct {
	BasePath string
	Wrap     HandlerWrapper
}

ExportRouteOptions configures export route registration.

type FeatureGates

type FeatureGates interface {
	Enabled(key string) bool
	Require(key string) error
}

FeatureGates exposes feature checks.

type FeatureOverridesBinding added in v0.20.0

type FeatureOverridesBinding interface {
	List(router.Context) (map[string]any, error)
	Set(router.Context, map[string]any) (map[string]any, error)
	Unset(router.Context, map[string]any) (map[string]any, error)
}

FeatureOverridesBinding exposes feature override mutations.

type HandlerWrapper

type HandlerWrapper func(router.HandlerFunc) router.HandlerFunc

HandlerWrapper wraps router handlers with auth or middleware.

type JobsBinding

type JobsBinding interface {
	List(router.Context) (map[string]any, error)
	Trigger(router.Context, map[string]any) error
}

JobsBinding exposes job operations.

type ListOptions

type ListOptions struct {
	Page     int
	PerPage  int
	SortBy   string
	SortDesc bool
	Filters  map[string]any
	Search   string
}

ListOptions holds pagination and filtering input for bindings.

type MediaBinding

type MediaBinding interface {
	List(router.Context) (map[string]any, error)
	Add(router.Context, map[string]any) (any, error)
}

MediaBinding exposes media operations.

type NavigationBinding interface {
	Resolve(router.Context, string, string) (items any, theme map[string]map[string]string)
}

NavigationBinding exposes navigation resolution.

type NotificationsBinding

type NotificationsBinding interface {
	List(router.Context) (map[string]any, error)
	Mark(router.Context, map[string]any) error
}

NotificationsBinding exposes notifications operations.

type PanelBinding

type PanelBinding interface {
	Name() string
	List(router.Context, string, ListOptions) ([]map[string]any, int, any, any, error)
	Detail(router.Context, string, string) (map[string]any, error)
	Create(router.Context, string, map[string]any) (map[string]any, error)
	Update(router.Context, string, string, map[string]any) (map[string]any, error)
	Delete(router.Context, string, string) error
	Action(router.Context, string, string, map[string]any) error
	Bulk(router.Context, string, string, map[string]any) error
}

PanelBinding exposes panel CRUD/action handlers for routes.

type Responder

type Responder interface {
	WriteJSON(router.Context, any) error
	WriteHTML(router.Context, string) error
	WriteError(router.Context, error) error
}

Responder centralizes response helpers.

type RouteSpec

type RouteSpec struct {
	Method  string
	Path    string
	Handler router.HandlerFunc
}

RouteSpec describes a route to register.

type Router

type Router interface {
	Get(path string, handler router.HandlerFunc, mw ...router.MiddlewareFunc) router.RouteInfo
	Post(path string, handler router.HandlerFunc, mw ...router.MiddlewareFunc) router.RouteInfo
	Put(path string, handler router.HandlerFunc, mw ...router.MiddlewareFunc) router.RouteInfo
	Delete(path string, handler router.HandlerFunc, mw ...router.MiddlewareFunc) router.RouteInfo
}

Router is the minimal router surface needed for boot steps.

type SearchBinding

type SearchBinding interface {
	Query(router.Context, string, string, int) ([]any, error)
}

SearchBinding exposes search queries.

type SettingsBinding

type SettingsBinding interface {
	Values(router.Context) (map[string]any, error)
	Form(router.Context) (any, error)
	Save(router.Context, map[string]any) (map[string]any, error)
}

SettingsBinding exposes settings operations.

type Step

type Step func(BootCtx) error

Step is a boot step executed during admin initialization.

func DefaultBootSteps

func DefaultBootSteps() []Step

DefaultBootSteps returns the built-in boot pipeline in registration order.

Jump to

Keyboard shortcuts

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