Update config.go
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 |
| ... | @@ -68,6 +69,8 @@ func init() { | ... | @@ -68,6 +69,8 @@ func init() { |
| 68 | 69 | ||
| 69 | StaticDir = make(map[string]string) | 70 | StaticDir = make(map[string]string) |
| 70 | StaticDir["/static"] = "static" | 71 | StaticDir["/static"] = "static" |
| 72 | |||
| 73 | StaticExtensionsToGzip = []string{".css", ".js"} | ||
| 71 | 74 | ||
| 72 | TemplateCache = make(map[string]*template.Template) | 75 | TemplateCache = make(map[string]*template.Template) |
| 73 | 76 | ||
| ... | @@ -273,6 +276,23 @@ func ParseConfig() (err error) { | ... | @@ -273,6 +276,23 @@ func ParseConfig() (err error) { |
| 273 | } | 276 | } |
| 274 | } | 277 | } |
| 275 | } | 278 | } |
| 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 | } | ||
| 276 | 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 | ... | ... |
-
Please register or sign in to post a comment