add json ASCII string render (#1358)

add a json render that rendering json as ASCII string
This commit is contained in:
Rex Lee(李俊)
2018-07-03 17:17:08 +08:00
committed by Bo-Yi Wu
parent d17a12591f
commit 85221af84c
5 changed files with 101 additions and 0 deletions

View File

@ -686,6 +686,17 @@ func TestContextRenderNoContentSecureJSON(t *testing.T) {
assert.Equal(t, "application/json; charset=utf-8", w.HeaderMap.Get("Content-Type"))
}
func TestContextRenderNoContentAsciiJSON(t *testing.T) {
w := httptest.NewRecorder()
c, _ := CreateTestContext(w)
c.AsciiJSON(http.StatusNoContent, []string{"lang", "Go语言"})
assert.Equal(t, http.StatusNoContent, w.Code)
assert.Empty(t, w.Body.String())
assert.Equal(t, "application/json", w.HeaderMap.Get("Content-Type"))
}
// Tests that the response executes the templates
// and responds with Content-Type set to text/html
func TestContextRenderHTML(t *testing.T) {