|
@ -8,7 +8,13 @@ import ( |
|
|
"strings" |
|
|
"strings" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* Default more not to gzip since gzip can be done on client side. |
|
|
|
|
|
*/ |
|
|
func IsGzippable(ext, mtype string) bool { |
|
|
func IsGzippable(ext, mtype string) bool { |
|
|
|
|
|
if strings.HasPrefix(mtype, "text/"){ |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
if ext == ".zip" { |
|
|
if ext == ".zip" { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
@ -18,11 +24,25 @@ func IsGzippable(ext, mtype string) bool { |
|
|
if ext == ".gz" { |
|
|
if ext == ".gz" { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
if strings.Index(mtype,"text/")==0 { |
|
|
|
|
|
|
|
|
if ext == ".pdf" { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
if ext == ".css" { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
if ext == ".js" { |
|
|
return true |
|
|
return true |
|
|
} |
|
|
} |
|
|
if strings.Index(mtype,"application/")==0 { |
|
|
|
|
|
|
|
|
if ext == ".json" { |
|
|
return true |
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
if strings.HasPrefix(mtype, "application/") { |
|
|
|
|
|
if strings.HasSuffix(mtype, "xml") { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
if strings.HasSuffix(mtype, "script") { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|