feat: support for gzip middleware (#53)

This commit is contained in:
Josef Hák
2019-04-03 04:59:18 +02:00
committed by Eason Lin
parent 9668210ca1
commit dbf6ef4100
10 changed files with 87 additions and 10 deletions
+11
View File
@@ -4,6 +4,7 @@ import (
"html/template"
"os"
"regexp"
"strings"
"golang.org/x/net/webdav"
@@ -61,6 +62,16 @@ func CustomWrapHandler(config *Config, h *webdav.Handler) gin.HandlerFunc {
prefix := matches[1]
h.Prefix = prefix
if strings.HasSuffix(path, ".html") {
c.Header("Content-Type", "text/html; charset=utf-8")
} else if strings.HasSuffix(path, ".css") {
c.Header("Content-Type", "text/css; charset=utf-8")
} else if strings.HasSuffix(path, ".js") {
c.Header("Content-Type", "application/javascript")
} else if strings.HasSuffix(path, ".json") {
c.Header("Content-Type", "application/json")
}
switch path {
case "index.html":
index.Execute(c.Writer, &swaggerUIBundle{