creating sse broker
This commit is contained in:
@@ -64,6 +64,9 @@ type Config struct {
|
||||
// default map[string]DatabaseConfig{}
|
||||
Databases map[string]DatabaseConfig
|
||||
|
||||
// default false
|
||||
CreateSSEBroker bool
|
||||
|
||||
// default false
|
||||
CreateTemplates bool
|
||||
|
||||
@@ -76,6 +79,8 @@ type Config struct {
|
||||
|
||||
type App struct {
|
||||
config Config
|
||||
Router *Router
|
||||
SSEBroker *SSEBroker
|
||||
Templates *Render
|
||||
Session *scs.SessionManager
|
||||
Mailer Mailer
|
||||
@@ -96,6 +101,7 @@ func NewApp(config ...Config) *App {
|
||||
Timezone: "UTC",
|
||||
Paseto: nil,
|
||||
Databases: make(map[string]DatabaseConfig),
|
||||
CreateSSEBroker: false,
|
||||
CreateSession: false,
|
||||
CreateMailer: false,
|
||||
CreateTemplates: false,
|
||||
@@ -189,6 +195,7 @@ func NewApp(config ...Config) *App {
|
||||
|
||||
app := &App{
|
||||
config: cfg,
|
||||
Router: newRouter(),
|
||||
}
|
||||
|
||||
slog.Info(
|
||||
@@ -201,6 +208,7 @@ func NewApp(config ...Config) *App {
|
||||
"paseto_public_key", cfg.Paseto.PublicKey.ExportHex(),
|
||||
"paseto_duration", cfg.Paseto.Duration.String(),
|
||||
"databases", cfg.Databases,
|
||||
"create_sse_broker", cfg.CreateSSEBroker,
|
||||
"create_templates", cfg.CreateTemplates,
|
||||
"create_session", cfg.CreateSession,
|
||||
"create_mailer", cfg.CreateMailer,
|
||||
@@ -210,6 +218,11 @@ func NewApp(config ...Config) *App {
|
||||
slog.Debug("paseto_assymetric_key", "key", cfg.Paseto.AsymmetricKey.ExportHex())
|
||||
}
|
||||
|
||||
if cfg.CreateSSEBroker {
|
||||
slog.Debug("creating sse broker")
|
||||
app.SSEBroker = newSSEBroker()
|
||||
}
|
||||
|
||||
if cfg.CreateTemplates {
|
||||
slog.Debug("creating templates")
|
||||
app.Templates = NewHTMLRender()
|
||||
|
||||
Reference in New Issue
Block a user