probo-app/app.go

40 lines
712 B
Go
Raw Normal View History

2023-06-29 10:52:15 +02:00
package main
import (
"context"
2023-07-03 18:18:59 +02:00
"git.andreafazzi.eu/andrea/probo/models"
2023-07-03 18:18:59 +02:00
"git.andreafazzi.eu/andrea/probo/store/file"
2023-06-29 10:52:15 +02:00
)
// App struct
type App struct {
2023-07-03 18:18:59 +02:00
ctx context.Context
store *file.FileProboCollectorStore
}
type Quiz struct {
Text string
2023-06-29 10:52:15 +02:00
}
// NewApp creates a new App application struct
func NewApp() *App {
2023-07-03 18:18:59 +02:00
store, err := file.NewFileProboCollectorStore("./data/quizzes")
if err != nil {
panic(err)
}
return &App{
store: store,
}
2023-06-29 10:52:15 +02:00
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}
func (a *App) ReadAllQuizzes() ([]*models.Quiz, error) {
return a.store.ReadAllQuizzes()
2023-07-03 18:18:59 +02:00
}