mirror of
https://github.com/astaxie/beego.git
synced 2024-11-23 00:40:54 +00:00
581e48679e
Fix issue 3866
28 lines
481 B
Go
28 lines
481 B
Go
package context
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"net/http"
|
|
)
|
|
|
|
const (
|
|
//BadRequest indicates HTTP error 400
|
|
BadRequest StatusCode = http.StatusBadRequest
|
|
|
|
//NotFound indicates HTTP error 404
|
|
NotFound StatusCode = http.StatusNotFound
|
|
)
|
|
|
|
// StatusCode sets the HTTP response status code
|
|
type StatusCode int
|
|
|
|
func (s StatusCode) Error() string {
|
|
return strconv.Itoa(int(s))
|
|
}
|
|
|
|
// Render sets the HTTP status code
|
|
func (s StatusCode) Render(ctx *Context) {
|
|
ctx.Output.SetStatus(int(s))
|
|
}
|