1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-06-15 00:15:15 +02:00

Optional minify response

This commit is contained in:
Lee Brown
2020-01-19 22:55:29 -09:00
parent ee5739fb10
commit 0ffe9de1e3
9 changed files with 97 additions and 1 deletions

View File

@ -102,6 +102,7 @@ func main() {
HostNames []string `envconfig:"HOST_NAMES" example:"alternative-subdomain.example.saasstartupkit.com"`
EnableHTTPS bool `default:"false" envconfig:"ENABLE_HTTPS"`
TemplateDir string `default:"./templates" envconfig:"TEMPLATE_DIR"`
Minify bool `envconfig:"MINIFY"`
DebugHost string `default:"0.0.0.0:4000" envconfig:"DEBUG_HOST"`
ShutdownTimeout time.Duration `default:"5s" envconfig:"SHUTDOWN_TIMEOUT"`
ScaleToZero time.Duration `envconfig:"SCALE_TO_ZERO"`
@ -491,6 +492,11 @@ func main() {
// Add the translator middleware for localization.
appCtx.PostAppMiddleware = append(appCtx.PostAppMiddleware, mid.Translator(webcontext.UniversalTranslator()))
// Apply response minification if enabled.
if cfg.Service.Minify {
appCtx.PostAppMiddleware = append(appCtx.PostAppMiddleware, mid.Minify())
}
// =========================================================================
// Start Tracing Support
th := fmt.Sprintf("%s:%d", cfg.Trace.Host, cfg.Trace.Port)