|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"git.phc.dm.unipi.it/phc/website/libs/db"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/libs/sl"
|
|
|
|
|
|
|
|
"git.phc.dm.unipi.it/phc/website/server"
|
|
|
|
|
|
|
|
"git.phc.dm.unipi.it/phc/website/server/config"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/server/database"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/server/listautenti"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/server/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
l := sl.New()
|
|
|
|
|
|
|
|
//
|
|
|
|
// Setup the application
|
|
|
|
//
|
|
|
|
|
|
|
|
// Config
|
|
|
|
sl.Provide(l, config.Slot, config.ExampleProductionConfig)
|
|
|
|
|
|
|
|
// Database
|
|
|
|
sl.Provide[database.Database](l, database.Slot, &database.Memory{
|
|
|
|
Users: []model.User{
|
|
|
|
{
|
|
|
|
Id: "e39ad8d5-a087-4cb2-8fd7-5a6ca3f6a534",
|
|
|
|
Username: "claire-doe",
|
|
|
|
FullName: db.NewOption("Claire Doe"),
|
|
|
|
Email: db.NewOption("claire.doe@example.org"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Id: "9b7109cd-95a1-41e9-a9f6-001a32c20ca1",
|
|
|
|
Username: "john-smith",
|
|
|
|
FullName: db.NewOption("John Smith"),
|
|
|
|
Email: db.NewOption("john.smith@example.org"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// Server
|
|
|
|
sl.ProvideFunc(l, server.Slot, server.Configure)
|
|
|
|
sl.ProvideHook(l, server.ApiRoutesHook,
|
|
|
|
listautenti.MountApiRoutesHook,
|
|
|
|
)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start the application
|
|
|
|
//
|
|
|
|
|
|
|
|
err := sl.Invoke(l, server.Slot)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|