Skip to content

Commit

Permalink
修复http状态码问题
Browse files Browse the repository at this point in the history
  • Loading branch information
gowater committed Feb 14, 2024
1 parent 7388b83 commit 3caab97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,13 @@ func bodyAllowedForStatus(status int) bool {

// Status sets the HTTP response code.
func (c *Context) Status(code int) {
c.Writer.WriteHeader(code)
if code > 0 && code != http.StatusOK {
c.Writer.WriteHeader(code)
}
}

func (c *Context) Render(code int, r render.Render) {
//c.Status(code)
c.Status(code)

if !bodyAllowedForStatus(code) {
r.WriteContentType(c.Writer)
Expand Down

0 comments on commit 3caab97

Please sign in to comment.