|
@@ -16,62 +16,68 @@ import (
|
|
|
|
|
|
var (
|
|
|
once sync.Once
|
|
|
- std *application
|
|
|
+ app Application
|
|
|
)
|
|
|
|
|
|
func initialization(cbs ...Option) {
|
|
|
once.Do(func() {
|
|
|
- std = New(cbs...)
|
|
|
+ app = New(cbs...)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
func Init(cbs ...Option) Application {
|
|
|
initialization(cbs...)
|
|
|
- return std
|
|
|
+ return app
|
|
|
}
|
|
|
|
|
|
func Name() string {
|
|
|
initialization()
|
|
|
- return std.opts.Name
|
|
|
+ return app.Info().Name
|
|
|
}
|
|
|
|
|
|
func ShortName() string {
|
|
|
initialization()
|
|
|
- return std.opts.ShortName()
|
|
|
+ if entry, ok := app.(*application); ok {
|
|
|
+ return entry.opts.ShortName()
|
|
|
+ }
|
|
|
+ return app.Info().Name
|
|
|
}
|
|
|
|
|
|
func Version() string {
|
|
|
initialization()
|
|
|
- return std.opts.Version
|
|
|
+ return app.Info().Version
|
|
|
}
|
|
|
|
|
|
func Debug(args ...any) bool {
|
|
|
initialization()
|
|
|
- if len(args) <= 0 {
|
|
|
- return std.opts.EnableDebug
|
|
|
- }
|
|
|
- if b, ok := args[0].(bool); ok {
|
|
|
- std.opts.EnableDebug = b
|
|
|
+ if entry, ok := app.(*application); ok {
|
|
|
+ if len(args) <= 0 {
|
|
|
+ return entry.opts.EnableDebug
|
|
|
+ }
|
|
|
+ if b, ok := args[0].(bool); ok {
|
|
|
+ entry.opts.EnableDebug = b
|
|
|
+ }
|
|
|
+ return entry.opts.EnableDebug
|
|
|
}
|
|
|
- return std.opts.EnableDebug
|
|
|
+ return false
|
|
|
}
|
|
|
|
|
|
func Node() *Info {
|
|
|
initialization()
|
|
|
- return std.Info()
|
|
|
+ return app.Info()
|
|
|
}
|
|
|
|
|
|
func Http() *http.Server {
|
|
|
initialization()
|
|
|
- return std.Http()
|
|
|
+ return app.Http()
|
|
|
}
|
|
|
|
|
|
func Command() *cli.Server {
|
|
|
initialization()
|
|
|
- return std.Command()
|
|
|
+ return app.Command()
|
|
|
}
|
|
|
|
|
|
func Handle(method string, cb HandleFunc) {
|
|
|
initialization()
|
|
|
- std.Handle(method, cb)
|
|
|
+ app.Handle(method, cb)
|
|
|
}
|