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:
singhwang
2021-08-12 04:26:37 +08:00
committed by GitHub
parent 8c37e9f279
commit 6322a8f797
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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
View File
@@ -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 {