added Content-Type header setting to wrap handler
to get work also with gin-contrib/gzip middleware
This commit is contained in:
parent
9668210ca1
commit
e9f890ab6b
11
swagger.go
11
swagger.go
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Reference in New Issue