Добавлление gzip
Теперь ответы сжимаются , что увеличивает скорость работы.
This commit is contained in:
@@ -170,10 +170,19 @@ func isRootFileRoutingEnabled(host string) bool {
|
||||
return site.Root_file_routing
|
||||
}
|
||||
}
|
||||
// По умолчанию роутинг выключен
|
||||
return false
|
||||
}
|
||||
|
||||
// Проверяет включено ли сжатие для сайта
|
||||
func isSiteCompressionEnabled(host string) bool {
|
||||
for _, site := range config.ConfigData.Site_www {
|
||||
if site.Host == host {
|
||||
return site.IsCompressionEnabled()
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Проверка vAccess с обработкой ошибки
|
||||
// Возвращает true если доступ разрешён, false если заблокирован
|
||||
func checkVAccessAndHandle(w http.ResponseWriter, r *http.Request, filePath string, host string) bool {
|
||||
@@ -246,6 +255,13 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
// Сжатие ответа (gzip)
|
||||
if isSiteCompressionEnabled(host) && clientAcceptsGzip(r) {
|
||||
gzw := newGzipResponseWriter(w)
|
||||
defer gzw.close()
|
||||
w = gzw
|
||||
}
|
||||
|
||||
// Проверяем существование директории сайта
|
||||
if _, err := os.Stat("WebServer/www/" + host + "/public_www"); err != nil {
|
||||
http.ServeFile(w, r, "WebServer/tools/error_page/index.html")
|
||||
|
||||
Reference in New Issue
Block a user