mirror of
https://github.com/gin-gonic/gin.git
synced 2026-07-09 20:29:16 +08:00
Compare commits
2 Commits
047a4c346e
...
001b56ec74
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
001b56ec74 | ||
|
|
1818d94c5f |
@ -1014,8 +1014,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