1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 18:10:49 +00:00
Beego/pkg/server/web/context/response.go

28 lines
481 B
Go
Raw Normal View History

2020-07-22 14:50:08 +00:00
package context
import (
"strconv"
"net/http"
)
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))
}