History

add png content-type headers (#169)

Bogdan U committed 5 years ago

Commit 3e21b591 parent c14c0de2 files · +14 −7Browse files

Unified · Split

2 files
  1. swagger.go +2 −0
  2. swagger_test.go +12 −7
swagger.go+2−0
@@ -99,6 +99,8 @@ func CustomWrapHandler(config *Config, handler *webdav.Handler) gin.HandlerFunc · 98 unmodified lines
9999 c.Header("Content-Type", "text/css; charset=utf-8")
100100 case ".js":
101101 c.Header("Content-Type", "application/javascript")
102+ case ".png":
103+ c.Header("Content-Type", "image/png")
102104 case ".json":
103105 c.Header("Content-Type", "application/json; charset=utf-8")
104106 }
swagger_test.go+12−7
@@ -3,7 +3,6 @@ package ginSwagger · 2 unmodified lines
33 import (
44 "net/http/httptest"
55 "os"
6− "path/filepath"
76 "testing"
87
98 "github.com/gin-contrib/gzip"
@@ -39,6 +38,7 @@ func TestWrapCustomHandler(t *testing.T) { · 29 unmodified lines
3938
4039 w1 := performRequest("GET", "/index.html", router)
4140 assert.Equal(t, 200, w1.Code)
41+ assert.Equal(t, w1.Header()["Content-Type"][0], "text/html; charset=utf-8")
4242
4343 w2 := performRequest("GET", "/doc.json", router)
4444 assert.Equal(t, 500, w2.Code)
@@ -50,9 +50,18 @@ func TestWrapCustomHandler(t *testing.T) { · 5 unmodified lines
5050
5151 w3 := performRequest("GET", "/favicon-16x16.png", router)
5252 assert.Equal(t, 200, w3.Code)
53+ assert.Equal(t, w3.Header()["Content-Type"][0], "image/png")
5354
54− w4 := performRequest("GET", "/notfound", router)
55− assert.Equal(t, 404, w4.Code)
55+ w4 := performRequest("GET", "/swagger-ui.css", router)
56+ assert.Equal(t, 200, w4.Code)
57+ assert.Equal(t, w4.Header()["Content-Type"][0], "text/css; charset=utf-8")
58+
59+ w5 := performRequest("GET", "/swagger-ui-bundle.js", router)
60+ assert.Equal(t, 200, w5.Code)
61+ assert.Equal(t, w5.Header()["Content-Type"][0], "application/javascript")
62+
63+ w6 := performRequest("GET", "/notfound", router)
64+ assert.Equal(t, 404, w6.Code)
5665 }
5766
5867 func TestDisablingWrapHandler(t *testing.T) {
@@ -200,7 +209,3 @@ func TestDefaultModelsExpandDepth(t *testing.T) { · 141 unmodified lines
200209 configFunc(&cfg)
201210 assert.Equal(t, expected, cfg.DefaultModelsExpandDepth)
202211 }
203−
204−func TestDeepLinking2(t *testing.T) {
205− t.Logf("extension: %s", filepath.Ext("/asas/index.html"))
206−}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t