Solve the integration swagger into the gin framework, access the Chinese garbled problem in the json returned by swagger/doc.json. (#78)
enable UTF8 for swagger json documentation
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@ func CustomWrapHandler(config *Config, h *webdav.Handler) gin.HandlerFunc {
|
||||
} else if strings.HasSuffix(path, ".js") {
|
||||
c.Header("Content-Type", "application/javascript")
|
||||
} else if strings.HasSuffix(path, ".json") {
|
||||
c.Header("Content-Type", "application/json")
|
||||
c.Header("Content-Type", "application/json; charset=utf-8")
|
||||
}
|
||||
|
||||
switch path {
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ func TestWithGzipMiddleware(t *testing.T) {
|
||||
|
||||
w4 := performRequest("GET", "/doc.json", router)
|
||||
assert.Equal(t, 200, w4.Code)
|
||||
assert.Equal(t, w4.Header()["Content-Type"][0], "application/json")
|
||||
assert.Equal(t, w4.Header()["Content-Type"][0], "application/json; charset=utf-8")
|
||||
}
|
||||
|
||||
func performRequest(method, target string, router *gin.Engine) *httptest.ResponseRecorder {
|
||||
|
||||
Reference in New Issue
Block a user