diff --git a/.gitignore b/.gitignore index cef4239..e056435 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.so -/types \ No newline at end of file +/types +/test \ No newline at end of file diff --git a/loader.go b/loader.go index 5de9785..ee8d2ce 100644 --- a/loader.go +++ b/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 } diff --git a/types.go b/types.go index 21002f1..c5d2ad4 100644 --- a/types.go +++ b/types.go @@ -1,13 +1,15 @@ package gfw import ( + "git.xdrm.io/gfw/checker" "git.xdrm.io/gfw/internal/config" ) type Server struct { - config *config.Controller - Params map[string]interface{} - err Err + config *config.Controller + Params map[string]interface{} + Checker *checker.TypeRegistry // type check + err Err } type Request struct {