import "hidevops.io/hiboot/pkg/app"
Package app provides abstract layer for cli/web application
Package app provides hiboot app application interface
application.go autoconfigure.go doc.go postprocessor.go properties.go
const ( // ApplicationContextName is the application context instance name ApplicationContextName = "app.applicationContext" ContextPathFormat = "server.context_path_format" ContextPathFormatKebab = "kebab" ContextPathFormatSnake = "snake" ContextPathFormatCamel = "camel" ContextPathFormatLowerCamel = "lower-camel" )
const ( // BannerDisabled is the property that allow use to enable / disable banner display on terminal BannerDisabled = "app.banner.disabled" // ProfilesInclude is the property that allow user include profiles at runtime ProfilesInclude = "app.profiles.include" // Version is the property key of app.version Version = "app.version" )
AutoConfiguration register auto configuration struct Deprecated: should use app.Register() instead.
Component register all component into container Deprecated: should use app.Register() instead.
var ( // ErrInvalidObjectType indicates that configuration type is invalid ErrInvalidObjectType = errors.New("[app] invalid Configuration type, one of app.Configuration need to be embedded") )
func Register(params ...interface{})
Register register a struct instance or constructor (func), so that it will be injectable.
func RegisterPostProcessor(p ...interface{})
RegisterPostProcessor register post processor
type Application interface { Initialize() error // TODO: remove it from factory as system.build can be injected directly SetProperty(name string, value ...interface{}) Application GetProperty(name string) (value interface{}, ok bool) SetAddCommandLineProperties(enabled bool) Application Run() }
Application is the base application interface
type ApplicationContext interface { RegisterController(controller interface{}) error Use(handlers ...context.Handler) GetProperty(name string) (value interface{}, ok bool) GetInstance(params ...interface{}) (instance interface{}) }
ApplicationContext is the alias interface of Application
BaseApplication is the base application
func (a *BaseApplication) AfterInitialization(configs ...cmap.ConcurrentMap)
AfterInitialization post initialization
func (a *BaseApplication) Build()
Initialize init application
func (a *BaseApplication) BuildConfigurations() (err error)
BuildConfigurations get BuildConfigurations
func (a *BaseApplication) ConfigurableFactory() factory.ConfigurableFactory
ConfigurableFactory get ConfigurableFactory
func (a *BaseApplication) GetInstance(params ...interface{}) (instance interface{})
GetInstance get application instance by name
func (a *BaseApplication) GetProperty(name string) (value interface{}, ok bool)
GetProperty get application property
func (a *BaseApplication) Initialize() (err error)
Initialize init application
func (a *BaseApplication) PrintStartupMessages()
PrintStartupMessages prints startup messages
func (a *BaseApplication) RegisterController(controller interface{}) error
RegisterController register controller by interface
func (a *BaseApplication) Run()
Run run the application
func (a *BaseApplication) SetAddCommandLineProperties(enabled bool) Application
SetAddCommandLineProperties set add command line properties to be enabled or disabled
func (a *BaseApplication) SetProperty(name string, value ...interface{}) Application
SetProperty set application property should be able to set property from source code by SetProperty, it can be override by program argument, e.g. myapp --app.profiles.active=dev
func (a *BaseApplication) SystemConfig() *system.Configuration
SystemConfig returns application config
func (a *BaseApplication) Use(handlers ...context.Handler)
Use use middleware handlers
type Configuration struct { at.AutoConfiguration RuntimeDeps factory.Deps }
Configuration is the base configuration
type PostProcessor interface {
AfterInitialization()
}
PostProcessor is the post processor
Path | Synopsis |
---|---|
cli | Package cli provides quick start framework for command line application. |
fake | Package fake provides fake.ApplicationContext for unit testing |
web | Package web provides quick start framework for web application. |
web/context |
Package app imports 15 packages (graph) and is imported by 45 packages. Updated 2019-10-15. Refresh now. Tools for package owners.