mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 13:50:54 +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
|
AppConfigPath string
|
||||||
StaticDir map[string]string
|
StaticDir map[string]string
|
||||||
TemplateCache map[string]*template.Template
|
TemplateCache map[string]*template.Template
|
||||||
|
StaticExtensionsToGzip []string //Files which should also be compressed with gzip (.js, .css, etc)
|
||||||
HttpAddr string
|
HttpAddr string
|
||||||
HttpPort int
|
HttpPort int
|
||||||
HttpTLS bool
|
HttpTLS bool
|
||||||
@ -68,6 +69,8 @@ func init() {
|
|||||||
|
|
||||||
StaticDir = make(map[string]string)
|
StaticDir = make(map[string]string)
|
||||||
StaticDir["/static"] = "static"
|
StaticDir["/static"] = "static"
|
||||||
|
|
||||||
|
StaticExtensionsToGzip = []string{".css", ".js"}
|
||||||
|
|
||||||
TemplateCache = make(map[string]*template.Template)
|
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 {
|
if enableadmin, err := AppConfig.Bool("EnableAdmin"); err == nil {
|
||||||
EnableAdmin = enableadmin
|
EnableAdmin = enableadmin
|
||||||
|
Loading…
Reference in New Issue
Block a user