Add PureJSON renderer (#694)

Closes #693
This commit is contained in:
Filip Figiel
2018-08-20 09:15:31 +02:00
committed by Bo-Yi Wu
parent b7bb9baa64
commit c6110f970c
8 changed files with 133 additions and 4 deletions

View File

@ -52,7 +52,8 @@ func TestRenderMsgPack(t *testing.T) {
func TestRenderJSON(t *testing.T) {
w := httptest.NewRecorder()
data := map[string]interface{}{
"foo": "bar",
"foo": "bar",
"html": "<b>",
}
(JSON{data}).WriteContentType(w)
@ -61,7 +62,7 @@ func TestRenderJSON(t *testing.T) {
err := (JSON{data}).Render(w)
assert.NoError(t, err)
assert.Equal(t, "{\"foo\":\"bar\"}", w.Body.String())
assert.Equal(t, "{\"foo\":\"bar\",\"html\":\"\\u003cb\\u003e\"}", w.Body.String())
assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
}