response.go 481 B

123456789101112131415161718192021222324252627
  1. package context
  2. import (
  3. "strconv"
  4. "net/http"
  5. )
  6. const (
  7. //BadRequest indicates http error 400
  8. BadRequest StatusCode = http.StatusBadRequest
  9. //NotFound indicates http error 404
  10. NotFound StatusCode = http.StatusNotFound
  11. )
  12. // StatusCode sets the http response status code
  13. type StatusCode int
  14. func (s StatusCode) Error() string {
  15. return strconv.Itoa(int(s))
  16. }
  17. // Render sets the http status code
  18. func (s StatusCode) Render(ctx *Context) {
  19. ctx.Output.SetStatus(int(s))
  20. }