This commit is contained in:
arshabbir 2024-11-19 13:32:03 +00:00 committed by GitHub
commit e68e51d784
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -975,8 +975,12 @@ func bodyAllowedForStatus(status int) bool {
} }
// Status sets the HTTP response code. // Status sets the HTTP response code.
func (c *Context) Status(code int) { func (c *Context) Status(code int) error {
if code > 0 {
c.Writer.WriteHeader(code) c.Writer.WriteHeader(code)
return nil
}
return errors.New("invalid status code")
} }
// Header is an intelligent shortcut for c.Writer.Header().Set(key, value). // Header is an intelligent shortcut for c.Writer.Header().Set(key, value).