Use json marshall in context json to fix breaking new line issue. Fixes #2209 (#2228)

* ignore IntelliJ idea generated files

* update JSON renderer to use Marshall() instead of Encode(). Fix #2209

* Revert "ignore IntelliJ idea generated files"

This reverts commit e7bd017227df5dbd2ed2f5fe353adb5f1b08c678.

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: thinkerou <thinkerou@gmail.com>
This commit is contained in:
Kaushik Neelichetty
2020-02-21 14:45:17 +05:30
committed by GitHub
parent 863ad2d4de
commit 5f56109bcf
5 changed files with 15 additions and 12 deletions

View File

@ -369,15 +369,15 @@ func TestErrorLogger(t *testing.T) {
w := performRequest(router, "GET", "/error")
assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "{\"error\":\"this is an error\"}\n", w.Body.String())
assert.Equal(t, "{\"error\":\"this is an error\"}", w.Body.String())
w = performRequest(router, "GET", "/abort")
assert.Equal(t, http.StatusUnauthorized, w.Code)
assert.Equal(t, "{\"error\":\"no authorized\"}\n", w.Body.String())
assert.Equal(t, "{\"error\":\"no authorized\"}", w.Body.String())
w = performRequest(router, "GET", "/print")
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Equal(t, "hola!{\"error\":\"this is an error\"}\n", w.Body.String())
assert.Equal(t, "hola!{\"error\":\"this is an error\"}", w.Body.String())
}
func TestLoggerWithWriterSkippingPaths(t *testing.T) {