1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-23 20:20:55 +00:00
Beego/server/web/context/response.go

27 lines
480 B
Go
Raw Normal View History

2020-07-22 14:50:08 +00:00
package context
import (
"net/http"
"strconv"
2020-07-22 14:50:08 +00:00
)
const (
2020-08-06 15:07:18 +00:00
//BadRequest indicates HTTP error 400
2020-07-22 14:50:08 +00:00
BadRequest StatusCode = http.StatusBadRequest
2020-08-06 15:07:18 +00:00
//NotFound indicates HTTP error 404
2020-07-22 14:50:08 +00:00
NotFound StatusCode = http.StatusNotFound
)
2020-08-06 15:07:18 +00:00
// StatusCode sets the HTTP response status code
2020-07-22 14:50:08 +00:00
type StatusCode int
func (s StatusCode) Error() string {
return strconv.Itoa(int(s))
}
2020-08-06 15:07:18 +00:00
// Render sets the HTTP status code
2020-07-22 14:50:08 +00:00
func (s StatusCode) Render(ctx *Context) {
ctx.Output.SetStatus(int(s))
}