added Content-Type header setting to wrap handler

to get work also with gin-contrib/gzip middleware
This commit is contained in:
hakjosef 2019-04-02 17:35:25 +02:00
parent 9668210ca1
commit e9f890ab6b
1 changed files with 11 additions and 0 deletions

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{