mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 12:12:12 +08:00
Merge 1818d94c5fe6dc89033952689bdf900a28c056c4 into 077a2f39c85700ba0823f85ed29cec0c8f2cbdfc
This commit is contained in:
commit
c27f69a5ca
@ -996,8 +996,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).
|
||||
|
Loading…
x
Reference in New Issue
Block a user