02eacb8e by Francois

Update config.go

1 parent 2a4459b9
Showing 1 changed file with 20 additions and 0 deletions
...@@ -19,6 +19,7 @@ var ( ...@@ -19,6 +19,7 @@ var (
19 AppConfigPath string 19 AppConfigPath string
20 StaticDir map[string]string 20 StaticDir map[string]string
21 TemplateCache map[string]*template.Template 21 TemplateCache map[string]*template.Template
22 StaticExtensionsToGzip []string //Files which should also be compressed with gzip (.js, .css, etc)
22 HttpAddr string 23 HttpAddr string
23 HttpPort int 24 HttpPort int
24 HttpTLS bool 25 HttpTLS bool
...@@ -69,6 +70,8 @@ func init() { ...@@ -69,6 +70,8 @@ func init() {
69 StaticDir = make(map[string]string) 70 StaticDir = make(map[string]string)
70 StaticDir["/static"] = "static" 71 StaticDir["/static"] = "static"
71 72
73 StaticExtensionsToGzip = []string{".css", ".js"}
74
72 TemplateCache = make(map[string]*template.Template) 75 TemplateCache = make(map[string]*template.Template)
73 76
74 // set this to 0.0.0.0 to make this app available to externally 77 // set this to 0.0.0.0 to make this app available to externally
...@@ -274,6 +277,23 @@ func ParseConfig() (err error) { ...@@ -274,6 +277,23 @@ func ParseConfig() (err error) {
274 } 277 }
275 } 278 }
276 279
280 if sgz := AppConfig.String("StaticExtensionsToGzip"); sgz != "" {
281 extensions := strings.Split(sgz, ",")
282 if len(extensions) > 0 {
283 StaticExtensionsToGzip = []string{}
284 for _, ext := range extensions {
285 if len(ext) == 0 {
286 continue
287 }
288 extWithDot := ext
289 if extWithDot[:1] != "." {
290 extWithDot = "." + extWithDot
291 }
292 StaticExtensionsToGzip = append(StaticExtensionsToGzip, extWithDot)
293 }
294 }
295 }
296
277 if enableadmin, err := AppConfig.Bool("EnableAdmin"); err == nil { 297 if enableadmin, err := AppConfig.Bool("EnableAdmin"); err == nil {
278 EnableAdmin = enableadmin 298 EnableAdmin = enableadmin
279 } 299 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!