Documentation ¶
Index ¶
- Variables
- func Env(def, key string, fallbacks ...string) string
- func Getenv(key string, fallbacks ...string) (value string)
- func LookupEnv(Key string, fallbacks ...string) (value string, found bool)
- type Component
- type ComponentFunc
- type Controller
- type ControllerURLGen
- type Kernel
- func (kernel *Kernel) AddControllers(contexts ...Controller)
- func (kernel *Kernel) AddHandler(method, path string, handler request.Handler, filters ...request.Handler)
- func (kernel *Kernel) AddHandlerContextName(registry *container.Registry, name, method, path string, ...)
- func (kernel *Kernel) AddHandlerFunc(method, path string, fn request.HandlerFunc, filters ...request.Handler)
- func (kernel *Kernel) AddHandlerName(name, method, path string, handler request.Handler, filters ...request.Handler)
- func (filterHandlers *Kernel) BindFilterFuncHandlers(filters ...request.HandlerFunc)
- func (filterHandlers *Kernel) BindFilterHandlers(filters ...request.Handler)
- func (kernel *Kernel) Bootstrap(b ...Component)
- func (kernel *Kernel) Container() *container.Registry
- func (kernel *Kernel) Dispatch(eventName string, payload event.Payload)
- func (kernel *Kernel) Dispose()
- func (kernel *Kernel) Fork() *Kernel
- func (kernel *Kernel) MustDispose()
- func (filterHandlers *Kernel) ResetMiddleHandlers()
- func (kernel *Kernel) Root() *Kernel
- func (kernel *Kernel) RunServer(host string) error
- func (kernel *Kernel) RunServerTLS(host, certfile, keyfile string) error
- func (kernel *Kernel) Snapshot() *Kernel
- func (kernel *Kernel) Subscribe(eventName string, handler interface{})
- type MapURLGen
- type Mapper
- type RunServerEvent
- type RunServerEventTLS
Constants ¶
This section is empty.
Variables ¶
var Default = New()
var KernelType = reflect.TypeOf((*Kernel)(nil))
Functions ¶
Types ¶
type Component ¶
type Component interface {
Bootstrap(app *Kernel)
}
Component represents a service component, a component need to implement a bootstrap method which is responsible to set up the component with the app, ex: register a type Providers, or add middleware handler
func NewComponentBundle ¶
func NewCtlComponent ¶
func NewCtlComponent(controllers ...Controller) Component
NewCtlComponent creates a component that will bind the passed context at bootstrap
type ComponentFunc ¶
type ComponentFunc func(*Kernel)
ComponentFunc func implementing Component interface
func (ComponentFunc) Bootstrap ¶
func (component ComponentFunc) Bootstrap(a *Kernel)
type Controller ¶
type Controller interface {
Mx(*Mapper)
}
type ControllerURLGen ¶
func (*ControllerURLGen) URL ¶
func (urlGen *ControllerURLGen) URL(dst string, v ...interface{}) string
type Kernel ¶
type Kernel struct { Registry *container.Registry // Kernel Registry dependency injection context Router *router.Router // Router Prefix string // Prefix prefix for path added in this app URLGen MapURLGen // contains filtered or unexported fields }
Kernel app holds your top level data for you service
Router, Dispatcher, Scope
func (*Kernel) AddControllers ¶
func (kernel *Kernel) AddControllers(contexts ...Controller)
func (*Kernel) AddHandler ¶
func (kernel *Kernel) AddHandler(method, path string, handler request.Handler, filters ...request.Handler)
AddHandler register a handler, see: request.Handler
func (*Kernel) AddHandlerContextName ¶
func (kernel *Kernel) AddHandlerContextName(registry *container.Registry, name, method, path string, handler request.Handler, filters ...request.Handler)
AddHandlerContextName accepts a context, a Name identifier, http method|methods, pattern path, handler and filters ex: one handler app.AddHandlerContextName(myContext,"mySectionIdentifier","GET", "/public",fileServer,checkAuth)
multiples handles app.AddHandlerContextName(myContext,"mySectionIdentifier","GET|POST|SEARCH", "/products",productHandler,checkAuth)
func (*Kernel) AddHandlerFunc ¶
func (kernel *Kernel) AddHandlerFunc(method, path string, fn request.HandlerFunc, filters ...request.Handler)
AddHandlerFunc register a func handler, see: request.Handler
func (*Kernel) AddHandlerName ¶
func (kernel *Kernel) AddHandlerName(name, method, path string, handler request.Handler, filters ...request.Handler)
AddHandlerName register a named handler, see: request.Handler
func (*Kernel) BindFilterFuncHandlers ¶
func (filterHandlers *Kernel) BindFilterFuncHandlers(filters ...request.HandlerFunc)
func (*Kernel) BindFilterHandlers ¶
BindFilterHandlers adds filters to the request chain
func (*Kernel) Bootstrap ¶
Bootstrap bootstraps a list of components, a sub scope will be created, and a copy of the original app is used, in such form that modifying the app.Prefix will not reflect outside this call.
func (*Kernel) Dispose ¶
func (kernel *Kernel) Dispose()
Dispose End same as app.Registry.End() invoke this func before exiting the app to cleanup
func (*Kernel) MustDispose ¶
func (kernel *Kernel) MustDispose()
func (*Kernel) ResetMiddleHandlers ¶
func (filterHandlers *Kernel) ResetMiddleHandlers()
ResetMiddleHandlers will clear the registered middlewares
func (*Kernel) RunServer ¶
RunServer runs the server with the specified host Calling this func will emit a "app.run" event in the app
func (*Kernel) RunServerTLS ¶
RunServerTLS runs the server in tls mode Calling this func will emit a "app.run.tls" event in the app
type Mapper ¶
type Mapper struct { Prefix string Name string Registry *container.Registry *ControllerURLGen // contains filtered or unexported fields }
func (*Mapper) BindAction ¶
func (*Mapper) BindFilterFuncHandlers ¶
func (filterHandlers *Mapper) BindFilterFuncHandlers(filters ...request.HandlerFunc)
func (*Mapper) BindFilterHandlers ¶
BindFilterHandlers adds filters to the request chain
func (*Mapper) ResetMiddleHandlers ¶
func (filterHandlers *Mapper) ResetMiddleHandlers()
ResetMiddleHandlers will clear the registered middlewares