mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 21:01:31 +00:00
Update config.go
This commit is contained in:
parent
2a4459b98b
commit
02eacb8e95
20
config.go
20
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
|
||||
@ -69,6 +70,8 @@ func init() {
|
||||
StaticDir = make(map[string]string)
|
||||
StaticDir["/static"] = "static"
|
||||
|
||||
StaticExtensionsToGzip = []string{".css", ".js"}
|
||||
|
||||
TemplateCache = make(map[string]*template.Template)
|
||||
|
||||
// set this to 0.0.0.0 to make this app available to externally
|
||||
@ -274,6 +277,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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user