Skip to content

Commit 5c6fa3f

Browse files
committed
Added json validation in render/json
Fixed send function issue
1 parent befffc2 commit 5c6fa3f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

context.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,19 @@ func (ctx *Context) Text(data string) {
136136
* Send data
137137
*/
138138
func (ctx *Context) send(data []byte, err error) {
139-
if ctx.end && err != nil {
139+
if ctx.end {
140140
return
141141
}
142+
143+
if err != nil {
144+
ctx.err = err
145+
return
146+
}
147+
142148
ctx.Response.WriteHeader(ctx.status)
143149
_, err = ctx.Response.Write(data)
150+
151+
//TODO: check - should not be recursive
144152
if err != nil {
145153
ctx.err = err
146154
return

render/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (j JSON) Write(w http.ResponseWriter) (data []byte, err error) {
3939
return
4040
}
4141

42-
if json.Valid(data) {
42+
if !json.Valid(data) {
4343
err = invalidJson
4444
return
4545
}

0 commit comments

Comments
 (0)