2023-04-23 17:57:36 +08:00
|
|
|
package kos
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.nspix.com/golang/kos/entry/cli"
|
|
|
|
"git.nspix.com/golang/kos/entry/http"
|
2023-07-07 09:53:37 +08:00
|
|
|
_ "git.nspix.com/golang/kos/pkg/request"
|
|
|
|
_ "git.nspix.com/golang/kos/util/bs"
|
2023-06-30 14:16:16 +08:00
|
|
|
_ "git.nspix.com/golang/kos/util/fetch"
|
|
|
|
_ "git.nspix.com/golang/kos/util/random"
|
|
|
|
_ "git.nspix.com/golang/kos/util/reflection"
|
2023-04-23 17:57:36 +08:00
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
once sync.Once
|
|
|
|
std *application
|
|
|
|
)
|
|
|
|
|
|
|
|
func initApplication(cbs ...Option) {
|
|
|
|
once.Do(func() {
|
|
|
|
std = New(cbs...)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func Init(cbs ...Option) *application {
|
|
|
|
initApplication(cbs...)
|
|
|
|
return std
|
|
|
|
}
|
|
|
|
|
|
|
|
func Node() *Info {
|
|
|
|
initApplication()
|
|
|
|
return std.Info()
|
|
|
|
}
|
|
|
|
|
|
|
|
func Http() *http.Server {
|
|
|
|
initApplication()
|
|
|
|
return std.Http()
|
|
|
|
}
|
|
|
|
|
|
|
|
func Command() *cli.Server {
|
|
|
|
initApplication()
|
|
|
|
return std.Command()
|
|
|
|
}
|
|
|
|
|
|
|
|
func Handle(method string, cb HandleFunc) {
|
|
|
|
initApplication()
|
|
|
|
std.Handle(method, cb)
|
|
|
|
}
|