add png content-type headers (#169)
This commit is contained in:
parent
c14c0debe8
commit
3e21b5982b
|
|
@ -99,6 +99,8 @@ func CustomWrapHandler(config *Config, handler *webdav.Handler) gin.HandlerFunc
|
|||
c.Header("Content-Type", "text/css; charset=utf-8")
|
||||
case ".js":
|
||||
c.Header("Content-Type", "application/javascript")
|
||||
case ".png":
|
||||
c.Header("Content-Type", "image/png")
|
||||
case ".json":
|
||||
c.Header("Content-Type", "application/json; charset=utf-8")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package ginSwagger
|
|||
import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-contrib/gzip"
|
||||
|
|
@ -39,6 +38,7 @@ func TestWrapCustomHandler(t *testing.T) {
|
|||
|
||||
w1 := performRequest("GET", "/index.html", router)
|
||||
assert.Equal(t, 200, w1.Code)
|
||||
assert.Equal(t, w1.Header()["Content-Type"][0], "text/html; charset=utf-8")
|
||||
|
||||
w2 := performRequest("GET", "/doc.json", router)
|
||||
assert.Equal(t, 500, w2.Code)
|
||||
|
|
@ -50,9 +50,18 @@ func TestWrapCustomHandler(t *testing.T) {
|
|||
|
||||
w3 := performRequest("GET", "/favicon-16x16.png", router)
|
||||
assert.Equal(t, 200, w3.Code)
|
||||
assert.Equal(t, w3.Header()["Content-Type"][0], "image/png")
|
||||
|
||||
w4 := performRequest("GET", "/notfound", router)
|
||||
assert.Equal(t, 404, w4.Code)
|
||||
w4 := performRequest("GET", "/swagger-ui.css", router)
|
||||
assert.Equal(t, 200, w4.Code)
|
||||
assert.Equal(t, w4.Header()["Content-Type"][0], "text/css; charset=utf-8")
|
||||
|
||||
w5 := performRequest("GET", "/swagger-ui-bundle.js", router)
|
||||
assert.Equal(t, 200, w5.Code)
|
||||
assert.Equal(t, w5.Header()["Content-Type"][0], "application/javascript")
|
||||
|
||||
w6 := performRequest("GET", "/notfound", router)
|
||||
assert.Equal(t, 404, w6.Code)
|
||||
}
|
||||
|
||||
func TestDisablingWrapHandler(t *testing.T) {
|
||||
|
|
@ -200,7 +209,3 @@ func TestDefaultModelsExpandDepth(t *testing.T) {
|
|||
configFunc(&cfg)
|
||||
assert.Equal(t, expected, cfg.DefaultModelsExpandDepth)
|
||||
}
|
||||
|
||||
func TestDeepLinking2(t *testing.T) {
|
||||
t.Logf("extension: %s", filepath.Ext("/asas/index.html"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue