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
99 c.Header("Content-Type", "text/css; charset=utf-8")99 c.Header("Content-Type", "text/css; charset=utf-8")
100 case ".js":100 case ".js":
101 c.Header("Content-Type", "application/javascript")101 c.Header("Content-Type", "application/javascript")
102 case ".png":
103 c.Header("Content-Type", "image/png")
102 case ".json":104 case ".json":
103 c.Header("Content-Type", "application/json; charset=utf-8")105 c.Header("Content-Type", "application/json; charset=utf-8")
104 }106 }
swagger_test.go+12−7
@@ -3,7 +3,6 @@ package ginSwagger · 2 unmodified lines
3import (3import (
4 "net/http/httptest"4 "net/http/httptest"
5 "os"5 "os"
6 "path/filepath"
7 "testing"6 "testing"
8 7
9 "github.com/gin-contrib/gzip"8 "github.com/gin-contrib/gzip"
@@ -39,6 +38,7 @@ func TestWrapCustomHandler(t *testing.T) { · 29 unmodified lines
39 38
40 w1 := performRequest("GET", "/index.html", router)39 w1 := performRequest("GET", "/index.html", router)
41 assert.Equal(t, 200, w1.Code)40 assert.Equal(t, 200, w1.Code)
41 assert.Equal(t, w1.Header()["Content-Type"][0], "text/html; charset=utf-8")
42 42
43 w2 := performRequest("GET", "/doc.json", router)43 w2 := performRequest("GET", "/doc.json", router)
44 assert.Equal(t, 500, w2.Code)44 assert.Equal(t, 500, w2.Code)
@@ -50,9 +50,18 @@ func TestWrapCustomHandler(t *testing.T) { · 5 unmodified lines
50 50
51 w3 := performRequest("GET", "/favicon-16x16.png", router)51 w3 := performRequest("GET", "/favicon-16x16.png", router)
52 assert.Equal(t, 200, w3.Code)52 assert.Equal(t, 200, w3.Code)
53 assert.Equal(t, w3.Header()["Content-Type"][0], "image/png")
53 54
54 w4 := performRequest("GET", "/notfound", router)55 w4 := performRequest("GET", "/swagger-ui.css", router)
55 assert.Equal(t, 404, w4.Code)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)
56}65}
57 66
58func TestDisablingWrapHandler(t *testing.T) {67func TestDisablingWrapHandler(t *testing.T) {
@@ -200,7 +209,3 @@ func TestDefaultModelsExpandDepth(t *testing.T) { · 141 unmodified lines
200 configFunc(&cfg)209 configFunc(&cfg)
201 assert.Equal(t, expected, cfg.DefaultModelsExpandDepth)210 assert.Equal(t, expected, cfg.DefaultModelsExpandDepth)
202}211}
203
204func 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