save the return line #3116

This commit is contained in:
arshabbir 2022-05-05 16:50:10 +05:30
parent 90e7073d56
commit 1818d94c5f
1 changed files with 6 additions and 2 deletions

View File

@ -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).