This commit is contained in:
Bel LaPointe
2019-02-18 09:31:35 -07:00
commit cbf886fb7e
14 changed files with 1016 additions and 0 deletions

30
server/new.go Normal file
View File

@@ -0,0 +1,30 @@
package server
import (
"local/s2sa/s2sa/server/router"
"local/s2sa/s2sa/services"
"local/s2sa/s2sa/storage"
)
func New(path string) *Server {
var db storage.DB
db = storage.NewMap()
if len(path) > 0 {
var err error
db, err = storage.NewBolt(path)
if err != nil {
return nil
}
}
authdb := storage.NewMap()
s := &Server{
db: services.New(db),
authdb: services.New(authdb),
router: router.New(),
addr: ":18341",
}
if err := s.authdb.Register(serverNS); err != nil {
panic(err)
}
return s
}