TestRenderSecureJSON() — gin Function Reference
Architecture documentation for the TestRenderSecureJSON() function in render_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD a5bb8700_c0e4_6ef7_9f36_edda4d544350["TestRenderSecureJSON()"] 067a4839_481a_7bd8_fc59_5c8c3313879c["render_test.go"] a5bb8700_c0e4_6ef7_9f36_edda4d544350 -->|defined in| 067a4839_481a_7bd8_fc59_5c8c3313879c style a5bb8700_c0e4_6ef7_9f36_edda4d544350 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
render/render_test.go lines 77–103
func TestRenderSecureJSON(t *testing.T) {
w1 := httptest.NewRecorder()
data := map[string]any{
"foo": "bar",
}
(SecureJSON{"while(1);", data}).WriteContentType(w1)
assert.Equal(t, "application/json; charset=utf-8", w1.Header().Get("Content-Type"))
err1 := (SecureJSON{"while(1);", data}).Render(w1)
require.NoError(t, err1)
assert.JSONEq(t, "{\"foo\":\"bar\"}", w1.Body.String())
assert.Equal(t, "application/json; charset=utf-8", w1.Header().Get("Content-Type"))
w2 := httptest.NewRecorder()
datas := []map[string]any{{
"foo": "bar",
}, {
"bar": "foo",
}}
err2 := (SecureJSON{"while(1);", datas}).Render(w2)
require.NoError(t, err2)
assert.Equal(t, "while(1);[{\"foo\":\"bar\"},{\"bar\":\"foo\"}]", w2.Body.String())
assert.Equal(t, "application/json; charset=utf-8", w2.Header().Get("Content-Type"))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestRenderSecureJSON() do?
TestRenderSecureJSON() is a function in the gin codebase, defined in render/render_test.go.
Where is TestRenderSecureJSON() defined?
TestRenderSecureJSON() is defined in render/render_test.go at line 77.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free