1
0
mirror of https://github.com/astaxie/beego.git synced 2025-02-16 22:47:02 +00:00
Beego/pkg/context/response.go

28 lines
481 B
Go
Raw Normal View History

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