refactor: new (simpler) version of the sl library
This commit is contained in:
+6
-14
@@ -6,22 +6,18 @@ import (
|
||||
"phc/website/services/config"
|
||||
"phc/website/services/database"
|
||||
"phc/website/services/server"
|
||||
"phc/website/services/server/dev"
|
||||
lista_utenti "phc/website/services/server/lista-utenti"
|
||||
"phc/website/sl"
|
||||
)
|
||||
|
||||
func main() {
|
||||
l := sl.New()
|
||||
|
||||
// sl.Inject[config.Interface](l, &config.EnvConfig{})
|
||||
|
||||
config := sl.InjectValue[config.Interface](l, &config.Custom{
|
||||
ModeValue: "production",
|
||||
HostValue: ":4000",
|
||||
cfg := sl.InjectValue(l, config.Slot, &config.Config{
|
||||
Mode: "production",
|
||||
Host: ":4000",
|
||||
})
|
||||
|
||||
sl.InjectValue[database.Database](l, &database.Memory{
|
||||
sl.InjectValue[database.Database](l, database.Slot, &database.Memory{
|
||||
Users: []model.User{
|
||||
{
|
||||
Id: "claire",
|
||||
@@ -38,14 +34,10 @@ func main() {
|
||||
},
|
||||
})
|
||||
|
||||
sl.Inject(l, &dev.Dev{})
|
||||
sl.Inject(l, &lista_utenti.ListaUtenti{})
|
||||
sl.Inject(l, &server.Server{})
|
||||
|
||||
server, err := sl.Use[*server.Server](l)
|
||||
srv, err := server.Configure(l)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Fatal(server.Router.Listen(config.Host()))
|
||||
log.Fatal(srv.Router.Listen(cfg.Host))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user