2023-05-20 20:15:57 +02:00
|
|
|
// Copyright 2023 wanderer <a_mirre at utb dot cz>
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2023-04-13 00:07:08 +02:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2023-05-03 02:18:29 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/app/settings"
|
2023-05-30 23:50:37 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent"
|
2023-04-19 02:12:27 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/slogging"
|
2023-05-09 17:35:00 +02:00
|
|
|
"golang.org/x/exp/slog"
|
2023-04-13 00:07:08 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2023-08-16 15:07:10 +02:00
|
|
|
setting *settings.Settings
|
|
|
|
appver string
|
|
|
|
appName = "pcmt"
|
|
|
|
appIsDevel bool
|
|
|
|
slogger *slogging.Slogger
|
|
|
|
log slogging.Slogger
|
|
|
|
dbclient *ent.Client
|
|
|
|
registrationAllowed bool
|
2023-04-13 00:07:08 +02:00
|
|
|
)
|
|
|
|
|
2023-05-30 23:50:37 +02:00
|
|
|
func SetDBClient(client *ent.Client) {
|
|
|
|
dbclient = client
|
|
|
|
}
|
|
|
|
|
2023-05-11 04:32:39 +02:00
|
|
|
func InitHandlers(s *settings.Settings) {
|
2023-05-11 17:06:20 +02:00
|
|
|
slogger = slogging.Logger()
|
2023-05-09 17:35:00 +02:00
|
|
|
log = *slogger // have a local copy.
|
|
|
|
log.Logger = log.Logger.With(
|
|
|
|
slog.Group("pcmt extra", slog.String("module", "handlers")),
|
|
|
|
)
|
2023-04-13 00:07:08 +02:00
|
|
|
|
2023-05-03 02:18:29 +02:00
|
|
|
setting = s
|
2023-04-13 00:07:08 +02:00
|
|
|
|
2023-08-15 18:33:48 +02:00
|
|
|
appName = setting.AppName()
|
2023-05-03 02:18:29 +02:00
|
|
|
appver = setting.Version()
|
2023-08-15 18:33:48 +02:00
|
|
|
appIsDevel = setting.IsDevel()
|
2023-08-16 15:07:10 +02:00
|
|
|
registrationAllowed = setting.RegistrationAllowed
|
2023-04-13 00:07:08 +02:00
|
|
|
}
|