Documentation
¶
Index ¶
- type ControllerConstructor
- type DynamicModule
- type MiddlewareConstructor
- type Module
- type ModuleOption
- func Controllers(constructors ...any) ModuleOption
- func Dynamic(factory func(...any) Module, opts ...any) ModuleOption
- func Imports(modules ...Module) ModuleOption
- func Middlewares(constructors ...any) ModuleOption
- func OnModuleDestroy(fn func() error) ModuleOption
- func OnModuleInit(fn func() error) ModuleOption
- func Providers(providers ...any) ModuleOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControllerConstructor ¶
type ControllerConstructor struct {
Fn any
}
ControllerConstructor holds a controller constructor.
type DynamicModule ¶
DynamicModule wraps a module factory with options.
type MiddlewareConstructor ¶
type MiddlewareConstructor struct {
Fn any
}
MiddlewareConstructor holds a middleware constructor.
type Module ¶
type Module struct {
Name string
Providers []any // Provider
Controllers []ControllerConstructor
Imports []Module
Middlewares []MiddlewareConstructor
OnInit []func() error
OnDestroy []func() error
Dynamic *DynamicModule
}
Module represents a self-contained unit of functionality.
func New ¶
func New(name string, opts ...ModuleOption) Module
New creates a new module with the given name and options.
type ModuleOption ¶
type ModuleOption func(*Module)
ModuleOption configures a Module.
func Controllers ¶
func Controllers(constructors ...any) ModuleOption
Controllers adds controller constructors that receive dependencies via DI.
func Dynamic ¶
func Dynamic(factory func(...any) Module, opts ...any) ModuleOption
Dynamic creates a module option for dynamic modules. The factory function receives the options and returns a configured module. Usage: ligo.Dynamic(NewConfigModule, folder)
func Middlewares ¶
func Middlewares(constructors ...any) ModuleOption
Middlewares adds middleware constructors that receive dependencies via DI.
func OnModuleDestroy ¶
func OnModuleDestroy(fn func() error) ModuleOption
OnModuleDestroy adds a hook to run when the module is destroyed.
func OnModuleInit ¶
func OnModuleInit(fn func() error) ModuleOption
OnModuleInit adds a hook to run when the module is initialized.
func Providers ¶
func Providers(providers ...any) ModuleOption
Providers adds providers to the module.