Adds supports for custom JSON Content-type

This commit is contained in:
Manu Mtz-Almeida
2015-06-13 04:29:10 +02:00
parent 22f118f3b6
commit a7c957af7d
4 changed files with 23 additions and 6 deletions

View File

@ -219,6 +219,18 @@ func TestContextRenderJSON(t *testing.T) {
assert.Equal(t, w.HeaderMap.Get("Content-Type"), "application/json; charset=utf-8")
}
// Tests that the response is serialized as JSON
// we change the content-type before
func TestContextRenderAPIJSON(t *testing.T) {
c, w, _ := createTestContext()
c.Header("Content-Type", "application/vnd.api+json")
c.JSON(201, H{"foo": "bar"})
assert.Equal(t, w.Code, 201)
assert.Equal(t, w.Body.String(), "{\"foo\":\"bar\"}\n")
assert.Equal(t, w.HeaderMap.Get("Content-Type"), "application/vnd.api+json")
}
// Tests that the response is serialized as JSON
// and Content-Type is set to application/json
func TestContextRenderIndentedJSON(t *testing.T) {