44 lines
608 B
Go
44 lines
608 B
Go
|
package kos
|
||
|
|
||
|
import (
|
||
|
"git.nspix.com/golang/kos/entry/cli"
|
||
|
"git.nspix.com/golang/kos/entry/http"
|
||
|
"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)
|
||
|
}
|