2024-09-26 17:54:14 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-09-27 14:52:10 +08:00
|
|
|
"github.com/loveuer/nf-disk/internal/api"
|
|
|
|
"github.com/loveuer/nf-disk/internal/db"
|
|
|
|
"github.com/loveuer/nf-disk/internal/model"
|
|
|
|
"github.com/loveuer/nf-disk/internal/tool"
|
|
|
|
"github.com/loveuer/nf-disk/ndh"
|
2024-09-26 17:54:14 +08:00
|
|
|
"github.com/loveuer/nf/nft/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
type App struct {
|
|
|
|
ctx context.Context
|
|
|
|
handlers map[string]ndh.Handler
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewApp() *App {
|
|
|
|
return &App{
|
|
|
|
handlers: make(map[string]ndh.Handler),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *App) Startup(ctx context.Context) {
|
|
|
|
log.Info("app startup!!!")
|
|
|
|
|
2024-09-27 14:52:10 +08:00
|
|
|
a.ctx = ctx
|
2024-09-26 17:54:14 +08:00
|
|
|
|
2024-09-27 14:52:10 +08:00
|
|
|
tool.Must(db.Init(ctx, "sqlite::memory", db.OptSqliteByMem(nil)))
|
|
|
|
tool.Must(model.Init(db.Default.Session()))
|
|
|
|
tool.Must(api.Init(ctx))
|
2024-09-26 17:54:14 +08:00
|
|
|
}
|