diff --git a/config.go b/config.go index 3a50ea67..8c4f9f7d 100644 --- a/config.go +++ b/config.go @@ -19,6 +19,7 @@ var ( AppConfigPath string StaticDir map[string]string TemplateCache map[string]*template.Template + StaticExtensionsToGzip []string //Files which should also be compressed with gzip (.js, .css, etc) HttpAddr string HttpPort int HttpTLS bool @@ -68,6 +69,8 @@ func init() { StaticDir = make(map[string]string) StaticDir["/static"] = "static" + + StaticExtensionsToGzip = []string{".css", ".js"} TemplateCache = make(map[string]*template.Template) @@ -273,6 +276,23 @@ func ParseConfig() (err error) { } } } + + if sgz := AppConfig.String("StaticExtensionsToGzip"); sgz != "" { + extensions := strings.Split(sgz, ",") + if len(extensions) > 0 { + StaticExtensionsToGzip = []string{} + for _, ext := range extensions { + if len(ext) == 0 { + continue + } + extWithDot := ext + if extWithDot[:1] != "." { + extWithDot = "." + extWithDot + } + StaticExtensionsToGzip = append(StaticExtensionsToGzip, extWithDot) + } + } + } if enableadmin, err := AppConfig.Bool("EnableAdmin"); err == nil { EnableAdmin = enableadmin