You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package listautenti
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
|
|
|
|
"git.phc.dm.unipi.it/phc/website/libs/sl"
|
|
|
|
|
|
|
|
"git.phc.dm.unipi.it/phc/website/server/database"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/server/routes"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ListaUtenti struct{}
|
|
|
|
|
|
|
|
var Slot = sl.NewSlot[*ListaUtenti]()
|
|
|
|
|
|
|
|
func Configure(l *sl.ServiceLocator) (*ListaUtenti, error) {
|
|
|
|
db, err := sl.Use(l, database.Slot)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
r, err := sl.Use(l, routes.Root)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
r.Get("/api/lista-utenti", func(c *fiber.Ctx) error {
|
|
|
|
users, err := db.ReadUsers()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Pre-process data to strip server only fields...
|
|
|
|
return c.JSON(users)
|
|
|
|
})
|
|
|
|
|
|
|
|
return &ListaUtenti{}, nil
|
|
|
|
}
|