Documentation
¶
Overview ¶
Package helix is the root package of the Helix framework - a Go backend framework inspired by Spring Boot.
See core for the DI container, web for HTTP routing, [data] for the repository pattern, and config for configuration loading.
Index ¶
- Variables
- func GetBean[T any](app *TestApp) T
- func RegisterWebSetup(fn func() error)
- func RegisterWireSetup(fn func(*core.Container) error)
- func Run(opts ...App) error
- type App
- type Component
- type ConfigReloadable
- type Controller
- type ErrorHandler
- type NotFoundError
- type Repository
- type RunMode
- type SecurityConfigurer
- type Service
- type TestApp
- type TestOption
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidComponent is returned when a value cannot be registered as a Helix component. ErrInvalidComponent = errors.New("helix: invalid component") // ErrScanRequiresComponents is returned when source scan finds marker types // that cannot be instantiated by the runtime bootstrap. ErrScanRequiresComponents = errors.New("helix: scan requires runtime components") )
Functions ¶
func RegisterWebSetup ¶
func RegisterWebSetup(fn func() error)
RegisterWebSetup stores the bootstrap function emitted by generated web route and handler registrations.
func RegisterWireSetup ¶
RegisterWireSetup stores the bootstrap function emitted by generated wiring.
func Run ¶
Run builds the default reflection-based container, registers application components, starts lifecycle hooks, waits for shutdown, and stops cleanly.
Run accepts an optional App argument. When called with no arguments (or with a zero-value App), the framework bootstraps automatically: it loads configuration from config/application.yaml or application.yaml (absence is not an error), auto-detects which starters to activate, and uses a registered wire setup function when available.
Types ¶
type App ¶
type App struct {
// Scan lists package or filesystem patterns that should be inspected for
// Helix component markers. Runtime scan cannot instantiate discovered Go
// types by itself; provide Components for values that should be registered.
Scan []string
// Components contains already-instantiated components to auto-register.
Components []any
// Starters lists the auto-configuration modules to activate before
// registering application components. Evaluated in canonical order.
Starters []starter.Entry
// ShutdownTimeout overrides the default lifecycle shutdown budget.
ShutdownTimeout time.Duration
// Logger overrides the logger used by lifecycle shutdown.
Logger *slog.Logger
// Mode selects the resolver strategy. The zero value keeps reflection mode.
Mode RunMode
// contains filtered or unexported fields
}
App describes the application bootstrap configuration used by Run.
type ConfigReloadable ¶
type ConfigReloadable = config.Reloadable
ConfigReloadable is implemented by components that react after a successful configuration reload.
type Controller ¶
type Controller struct{}
Controller marks a struct as a Helix controller component.
type ErrorHandler ¶
type ErrorHandler struct{}
ErrorHandler marks a struct as a centralized HTTP error handler component.
type NotFoundError ¶
type NotFoundError struct {
Message string
}
NotFoundError represents a missing resource returned by application code.
func (NotFoundError) ErrorCode ¶
func (e NotFoundError) ErrorCode() string
ErrorCode returns the machine-readable error code.
func (NotFoundError) ErrorField ¶
func (e NotFoundError) ErrorField() string
ErrorField returns the field associated with this error, when any.
func (NotFoundError) ErrorType ¶
func (e NotFoundError) ErrorType() string
ErrorType returns the structured error type name.
func (NotFoundError) StatusCode ¶
func (e NotFoundError) StatusCode() int
StatusCode returns the HTTP status associated with this error.
type Repository ¶
type Repository struct{}
Repository marks a struct as a Helix repository component.
type SecurityConfigurer ¶
type SecurityConfigurer struct{}
SecurityConfigurer marks a struct as a global security configuration component.
type TestApp ¶
TestApp is a Helix application container scoped to a Go test.
func NewTestApp ¶
func NewTestApp(t testing.TB, opts ...TestOption) *TestApp
NewTestApp creates, starts, and registers cleanup for a Helix test app.
type TestOption ¶
TestOption configures a Helix test application.
func MockBean ¶
func MockBean[T any](impl T) TestOption
MockBean replaces components assignable to T with impl in a Helix test app.
func TestComponents ¶
func TestComponents(components ...any) TestOption
TestComponents registers components in the test container before startup.
func TestConfigDefaults ¶
func TestConfigDefaults(values map[string]any) TestOption
TestConfigDefaults configures fallback values for the test config loader.
func TestConfigPaths ¶
func TestConfigPaths(paths ...string) TestOption
TestConfigPaths overrides directories searched for application test config.
func TestContainerOptions ¶
func TestContainerOptions(opts ...core.Option) TestOption
TestContainerOptions appends core container options to the test container.
type ValidationError ¶
ValidationError represents invalid user input returned by application code.
func (ValidationError) ErrorCode ¶
func (e ValidationError) ErrorCode() string
ErrorCode returns the machine-readable error code.
func (ValidationError) ErrorField ¶
func (e ValidationError) ErrorField() string
ErrorField returns the field associated with this error, when any.
func (ValidationError) ErrorType ¶
func (e ValidationError) ErrorType() string
ErrorType returns the structured error type name.
func (ValidationError) StatusCode ¶
func (e ValidationError) StatusCode() int
StatusCode returns the HTTP status associated with this error.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli provides the Helix project and module generator CLI tool (e.g.
|
Package cli provides the Helix project and module generator CLI tool (e.g. |
|
cmd
|
|
|
helix
command
|
|
|
Package config provides YAML and ENV configuration loading with priority chain ENV > profile YAML > application.yaml > DEFAULT for the Helix framework.
|
Package config provides YAML and ENV configuration loading with priority chain ENV > profile YAML > application.yaml > DEFAULT for the Helix framework. |
|
Package core provides the dependency injection container and lifecycle management for the Helix framework.
|
Package core provides the dependency injection container and lifecycle management for the Helix framework. |
|
Package data provides the generic repository pattern and ORM adapter interfaces for the Helix framework.
|
Package data provides the generic repository pattern and ORM adapter interfaces for the Helix framework. |
|
gorm
Package gorm provides the GORM-based implementation of the Helix repository interfaces.
|
Package gorm provides the GORM-based implementation of the Helix repository interfaces. |
|
examples
|
|
|
crud-api
command
|
|
|
secured-api
command
|
|
|
zero-config
command
Package main demonstrates the zero-config bootstrap mode of the Helix framework.
|
Package main demonstrates the zero-config bootstrap mode of the Helix framework. |
|
Package observability provides Prometheus metrics, structured logging via slog, and OpenTelemetry tracing for the Helix framework.
|
Package observability provides Prometheus metrics, structured logging via slog, and OpenTelemetry tracing for the Helix framework. |
|
Package scheduler provides declarative task scheduling support, backed by a robfig/cron adapter, for the Helix framework.
|
Package scheduler provides declarative task scheduling support, backed by a robfig/cron adapter, for the Helix framework. |
|
Package security provides JWT authentication, RBAC middleware, and security configuration for the Helix framework.
|
Package security provides JWT authentication, RBAC middleware, and security configuration for the Helix framework. |
|
Package starter provides auto-configuration modules (web, data, security, observability) for the Helix framework.
|
Package starter provides auto-configuration modules (web, data, security, observability) for the Helix framework. |
|
internal/starterutil
Package starterutil provides shared helpers for Helix starters.
|
Package starterutil provides shared helpers for Helix starters. |
|
Package testutil provides testing helpers, mock beans, and test application container utilities for the Helix framework.
|
Package testutil provides testing helpers, mock beans, and test application container utilities for the Helix framework. |
|
Package web provides HTTP integration, declarative routing, and middleware support for the Helix framework, built on top of Fiber.
|
Package web provides HTTP integration, declarative routing, and middleware support for the Helix framework, built on top of Fiber. |
|
internal
Package internal contains internal Fiber adapter implementation details not exposed as part of the public web package API.
|
Package internal contains internal Fiber adapter implementation details not exposed as part of the public web package API. |