From 5c5a51f9b1b9609b2b05d9cabd1e8331a803de0b Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 16 Jul 2020 17:01:44 +0200 Subject: [PATCH] feature: add debug mode in configuration - automatically reload HTML templates when debug mode is activated (no rebuild necessary) --- cmd/server/container.go.gotpl | 1 + internal/config/config.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/server/container.go.gotpl b/cmd/server/container.go.gotpl index 124609a..ff944fe 100644 --- a/cmd/server/container.go.gotpl +++ b/cmd/server/container.go.gotpl @@ -68,6 +68,7 @@ func getServiceContainer(conf *config.Config) (*service.Container, error) { // Create and expose template service provider ctn.Provide(template.ServiceName, html.ServiceProvider( html.NewDirectoryLoader(conf.HTTP.TemplateDir), + html.WithDevMode(conf.Debug), )) // Create and expose config service provider diff --git a/internal/config/config.go b/internal/config/config.go index 38d9394..42688cc 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -11,7 +11,8 @@ import ( ) type Config struct { - HTTP HTTPConfig `yaml:"http"` + Debug bool `yaml:"debug"` + HTTP HTTPConfig `yaml:"http"` } // NewFromFile retrieves the configuration from the given file @@ -46,6 +47,7 @@ func NewDumpDefault() *Config { func NewDefault() *Config { return &Config{ + Debug: false, HTTP: HTTPConfig{ Address: ":3000", CookieAuthenticationKey: "",