Init() now takes a TypeRegistry as 2nd arg, if NIL, use default settings (./types/*.so)"
This commit is contained in:
parent
812831a665
commit
a777de0096
|
@ -1,2 +1,3 @@
|
|||
*.so
|
||||
/types
|
||||
/test
|
22
loader.go
22
loader.go
|
@ -1,9 +1,18 @@
|
|||
package gfw
|
||||
|
||||
import "git.xdrm.io/gfw/internal/config"
|
||||
import (
|
||||
"git.xdrm.io/gfw/checker"
|
||||
"git.xdrm.io/gfw/internal/config"
|
||||
)
|
||||
|
||||
// Init initilises a new framework instance
|
||||
func Init(path string) (*Server, error) {
|
||||
//
|
||||
// - path is the configuration path
|
||||
//
|
||||
// - if typeChecker is nil, defaults will be used (all *.so files
|
||||
// inside ./types local directory)
|
||||
//
|
||||
func Init(path string, typeChecker *checker.TypeRegistry) (*Server, error) {
|
||||
|
||||
/* (1) Init instance */
|
||||
inst := &Server{
|
||||
|
@ -19,5 +28,14 @@ func Init(path string) (*Server, error) {
|
|||
}
|
||||
inst.config = config
|
||||
|
||||
/* (3) Store registry if not nil */
|
||||
if typeChecker != nil {
|
||||
inst.Checker = typeChecker
|
||||
return inst, nil
|
||||
}
|
||||
|
||||
/* (4) Default registry creation */
|
||||
inst.Checker = checker.CreateRegistry(true)
|
||||
|
||||
return inst, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue