diff --git a/context.go b/context.go index 5e53aaf0..059c3bd0 100644 --- a/context.go +++ b/context.go @@ -824,8 +824,12 @@ func bodyAllowedForStatus(status int) bool { } // Status sets the HTTP response code. -func (c *Context) Status(code int) { - c.Writer.WriteHeader(code) +func (c *Context) Status(code int) error { + if code > 0 { + c.Writer.WriteHeader(code) + return nil + } + return errors.New("invalid status code") } // Header is an intelligent shortcut for c.Writer.Header().Set(key, value).