pcmt/handlers/config.go
leo dbd0e9d01d
All checks were successful
continuous-integration/drone/push Build is passing
go: implement session auth middleware
* simplify protection of endpoints
* role discernment still occures in respective handlers
* db client needs to be passed into handlers as a global var now
2023-05-30 23:50:37 +02:00

36 lines
709 B
Go

// Copyright 2023 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: AGPL-3.0-only
package handlers
import (
"git.dotya.ml/mirre-mt/pcmt/app/settings"
"git.dotya.ml/mirre-mt/pcmt/ent"
"git.dotya.ml/mirre-mt/pcmt/slogging"
"golang.org/x/exp/slog"
)
var (
setting *settings.Settings
appver string
slogger *slogging.Slogger
log slogging.Slogger
dbclient *ent.Client
)
func SetDBClient(client *ent.Client) {
dbclient = client
}
func InitHandlers(s *settings.Settings) {
slogger = slogging.Logger()
log = *slogger // have a local copy.
log.Logger = log.Logger.With(
slog.Group("pcmt extra", slog.String("module", "handlers")),
)
setting = s
appver = setting.Version()
}